Performance Timeline: Prepare for Worker support
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2017 22:08:21 +0000 (22:08 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Feb 2017 22:08:21 +0000 (22:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167633

Reviewed by Ryosuke Niwa.

Remove references to Document/Frame in Performance. Instead use
ScriptExecutionContext and pass in the time origin / SecurityOrigin
where it is relevant. No tests should change this is just refactoring.

* loader/ResourceTimingInformation.cpp:
(WebCore::ResourceTimingInformation::addResourceTiming):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::performance):
* page/Performance.cpp:
(WebCore::Performance::Performance):
(WebCore::Performance::now):
(WebCore::Performance::reduceTimeResolution):
(WebCore::Performance::navigation):
(WebCore::Performance::timing):
(WebCore::Performance::addResourceTiming):
(WebCore::Performance::scriptExecutionContext): Deleted.
* page/Performance.h:
* page/Performance.idl:
* page/PerformanceResourceTiming.cpp:
(WebCore::monotonicTimeToDOMHighResTimeStamp):
(WebCore::passesTimingAllowCheck):
(WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
(WebCore::PerformanceResourceTiming::redirectStart):
(WebCore::PerformanceResourceTiming::redirectEnd):
(WebCore::PerformanceResourceTiming::fetchStart):
(WebCore::PerformanceResourceTiming::domainLookupStart):
(WebCore::PerformanceResourceTiming::domainLookupEnd):
(WebCore::PerformanceResourceTiming::connectStart):
(WebCore::PerformanceResourceTiming::connectEnd):
(WebCore::PerformanceResourceTiming::secureConnectionStart):
(WebCore::PerformanceResourceTiming::requestStart):
(WebCore::PerformanceResourceTiming::responseStart):
(WebCore::PerformanceResourceTiming::responseEnd):
(WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
(WebCore::monotonicTimeToDocumentMilliseconds): Deleted.
(WebCore::PerformanceResourceTiming::initiatorType): Deleted.
(WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds): Deleted.
* page/PerformanceResourceTiming.h:
* page/PerformanceUserTiming.cpp:
(WebCore::UserTiming::findExistingMarkStartTime):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211527 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceTimingInformation.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h
Source/WebCore/page/Performance.idl
Source/WebCore/page/PerformanceResourceTiming.cpp
Source/WebCore/page/PerformanceResourceTiming.h
Source/WebCore/page/PerformanceUserTiming.cpp

index ec7faad..2586ddf 100644 (file)
@@ -1,3 +1,51 @@
+2017-02-01  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Performance Timeline: Prepare for Worker support
+        https://bugs.webkit.org/show_bug.cgi?id=167633
+
+        Reviewed by Ryosuke Niwa.
+
+        Remove references to Document/Frame in Performance. Instead use
+        ScriptExecutionContext and pass in the time origin / SecurityOrigin
+        where it is relevant. No tests should change this is just refactoring.
+
+        * loader/ResourceTimingInformation.cpp:
+        (WebCore::ResourceTimingInformation::addResourceTiming):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::performance):
+        * page/Performance.cpp:
+        (WebCore::Performance::Performance):
+        (WebCore::Performance::now):
+        (WebCore::Performance::reduceTimeResolution):
+        (WebCore::Performance::navigation):
+        (WebCore::Performance::timing):
+        (WebCore::Performance::addResourceTiming):
+        (WebCore::Performance::scriptExecutionContext): Deleted.
+        * page/Performance.h:
+        * page/Performance.idl:
+        * page/PerformanceResourceTiming.cpp:
+        (WebCore::monotonicTimeToDOMHighResTimeStamp):
+        (WebCore::passesTimingAllowCheck):
+        (WebCore::PerformanceResourceTiming::PerformanceResourceTiming):
+        (WebCore::PerformanceResourceTiming::redirectStart):
+        (WebCore::PerformanceResourceTiming::redirectEnd):
+        (WebCore::PerformanceResourceTiming::fetchStart):
+        (WebCore::PerformanceResourceTiming::domainLookupStart):
+        (WebCore::PerformanceResourceTiming::domainLookupEnd):
+        (WebCore::PerformanceResourceTiming::connectStart):
+        (WebCore::PerformanceResourceTiming::connectEnd):
+        (WebCore::PerformanceResourceTiming::secureConnectionStart):
+        (WebCore::PerformanceResourceTiming::requestStart):
+        (WebCore::PerformanceResourceTiming::responseStart):
+        (WebCore::PerformanceResourceTiming::responseEnd):
+        (WebCore::PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp):
+        (WebCore::monotonicTimeToDocumentMilliseconds): Deleted.
+        (WebCore::PerformanceResourceTiming::initiatorType): Deleted.
+        (WebCore::PerformanceResourceTiming::resourceTimeToDocumentMilliseconds): Deleted.
+        * page/PerformanceResourceTiming.h:
+        * page/PerformanceUserTiming.cpp:
+        (WebCore::UserTiming::findExistingMarkStartTime):
+
 2017-02-01  Chris Dumez  <cdumez@apple.com>
 
         REGRESSION(r205136): {}.toString.call(crossOriginWindow) should not throw
index 8ff4489..9b5d811 100644 (file)
@@ -53,7 +53,7 @@ void ResourceTimingInformation::addResourceTiming(CachedResource* resource, Docu
             ASSERT(initiatorDocument->domWindow());
             ASSERT(initiatorDocument->domWindow()->performance());
             const InitiatorInfo& info = initiatorIt->value;
-            initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, initiatorDocument, resource->resourceRequest().url(), resource->response(), loadTiming);
+            initiatorDocument->domWindow()->performance()->addResourceTiming(info.name, resource->resourceRequest().url(), resource->response(), loadTiming);
             initiatorIt->value.added = Added;
         }
     }
index 8616e09..c2f5794 100644 (file)
@@ -799,8 +799,10 @@ Performance* DOMWindow::performance() const
 {
     if (!isCurrentlyDisplayedInFrame())
         return nullptr;
-    if (!m_performance)
-        m_performance = Performance::create(*m_frame);
+    if (!m_performance) {
+        double timeOrigin = document()->loader() ? document()->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime();
+        m_performance = Performance::create(*document(), timeOrigin);
+    }
     return m_performance.get();
 }
 
index 3283c9a..5b43309 100644 (file)
 #include "PerformanceTiming.h"
 #include "PerformanceUserTiming.h"
 #include "ResourceResponse.h"
+#include "ScriptExecutionContext.h"
 #include <wtf/CurrentTime.h>
 
 namespace WebCore {
 
-Performance::Performance(Frame& frame)
-    : DOMWindowProperty(&frame)
-    , m_referenceTime(frame.document()->loader() ? frame.document()->loader()->timing().referenceMonotonicTime() : monotonicallyIncreasingTime())
+Performance::Performance(ScriptExecutionContext& context, double timeOrigin)
+    : ContextDestructionObserver(&context)
+    , m_timeOrigin(timeOrigin)
 {
-    ASSERT(m_referenceTime);
+    ASSERT(m_timeOrigin);
 }
 
 Performance::~Performance()
 {
 }
 
-ScriptExecutionContext* Performance::scriptExecutionContext() const
+double Performance::now() const
 {
-    if (!frame())
-        return nullptr;
-    return frame()->document();
+    double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin;
+    return 1000.0 * reduceTimeResolution(nowSeconds);
 }
 
-PerformanceNavigation& Performance::navigation()
+double Performance::reduceTimeResolution(double seconds)
 {
+    const double resolutionSeconds = 0.0001;
+    return std::floor(seconds / resolutionSeconds) * resolutionSeconds;
+}
+
+PerformanceNavigation* Performance::navigation()
+{
+    if (!is<Document>(scriptExecutionContext()))
+        return nullptr;
+
+    ASSERT(isMainThread());
     if (!m_navigation)
-        m_navigation = PerformanceNavigation::create(m_frame);
-    return *m_navigation;
+        m_navigation = PerformanceNavigation::create(downcast<Document>(*scriptExecutionContext()).frame());
+    return m_navigation.get();
 }
 
-PerformanceTiming& Performance::timing()
+PerformanceTiming* Performance::timing()
 {
+    if (!is<Document>(scriptExecutionContext()))
+        return nullptr;
+
+    ASSERT(isMainThread());
     if (!m_timing)
-        m_timing = PerformanceTiming::create(m_frame);
-    return *m_timing;
+        m_timing = PerformanceTiming::create(downcast<Document>(*scriptExecutionContext()).frame());
+    return m_timing.get();
 }
 
 Vector<RefPtr<PerformanceEntry>> Performance::getEntries() const
@@ -150,12 +164,16 @@ void Performance::setResourceTimingBufferSize(unsigned size)
         dispatchEvent(Event::create(eventNames().resourcetimingbufferfullEvent, false, false));
 }
 
-void Performance::addResourceTiming(const String& initiatorName, Document* initiatorDocument, const URL& originalURL, const ResourceResponse& response, const LoadTiming& loadTiming)
+void Performance::addResourceTiming(const String& initiatorName, const URL& originalURL, const ResourceResponse& response, const LoadTiming& loadTiming)
 {
     if (isResourceTimingBufferFull())
         return;
 
-    RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(initiatorName, originalURL, response, loadTiming, initiatorDocument);
+    SecurityOrigin* securityOrigin = scriptExecutionContext()->securityOrigin();
+    if (!securityOrigin)
+        return;
+
+    RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(initiatorName, originalURL, response, *securityOrigin, m_timeOrigin, loadTiming);
 
     m_resourceTimingBuffer.append(entry);
 
@@ -220,18 +238,6 @@ void Performance::unregisterPerformanceObserver(PerformanceObserver& observer)
     m_observers.remove(&observer);
 }
 
-double Performance::now() const
-{
-    double nowSeconds = monotonicallyIncreasingTime() - m_referenceTime;
-    return 1000.0 * reduceTimeResolution(nowSeconds);
-}
-
-double Performance::reduceTimeResolution(double seconds)
-{
-    const double resolutionSeconds = 0.0001;
-    return std::floor(seconds / resolutionSeconds) * resolutionSeconds;
-}
-
 void Performance::queueEntry(PerformanceEntry& entry)
 {
     bool shouldScheduleTask = false;
index f7414fc..b43fcc2 100644 (file)
@@ -34,7 +34,7 @@
 
 #if ENABLE(WEB_TIMING)
 
-#include "DOMWindowProperty.h"
+#include "ContextDestructionObserver.h"
 #include "EventTarget.h"
 #include "ExceptionOr.h"
 #include "GenericTaskQueue.h"
 
 namespace WebCore {
 
-class Document;
 class LoadTiming;
 class PerformanceEntry;
 class PerformanceNavigation;
 class PerformanceObserver;
 class PerformanceTiming;
 class ResourceResponse;
+class ScriptExecutionContext;
 class URL;
 class UserTiming;
 
-class Performance final : public RefCounted<Performance>, public DOMWindowProperty, public EventTargetWithInlineData {
+class Performance final : public RefCounted<Performance>, public ContextDestructionObserver, public EventTargetWithInlineData {
 public:
-    static Ref<Performance> create(Frame& frame) { return adoptRef(*new Performance(frame)); }
+    static Ref<Performance> create(ScriptExecutionContext& context, double timeOrigin) { return adoptRef(*new Performance(context, timeOrigin)); }
     ~Performance();
 
-    PerformanceNavigation& navigation();
-    PerformanceTiming& timing();
     double now() const;
 
+    PerformanceNavigation* navigation();
+    PerformanceTiming* timing();
+
     Vector<RefPtr<PerformanceEntry>> getEntries() const;
     Vector<RefPtr<PerformanceEntry>> getEntriesByType(const String& entryType) const;
     Vector<RefPtr<PerformanceEntry>> getEntriesByName(const String& name, const String& entryType) const;
@@ -68,7 +69,7 @@ public:
     void clearResourceTimings();
     void setResourceTimingBufferSize(unsigned);
 
-    void addResourceTiming(const String& initiatorName, Document*, const URL& originalURL, const ResourceResponse&, const LoadTiming&);
+    void addResourceTiming(const String& initiatorName, const URL& originalURL, const ResourceResponse&, const LoadTiming&);
 
     ExceptionOr<void> mark(const String& markName);
     void clearMarks(const String& markName);
@@ -81,14 +82,15 @@ public:
 
     static double reduceTimeResolution(double seconds);
 
+    ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
+
     using RefCounted::ref;
     using RefCounted::deref;
 
 private:
-    explicit Performance(Frame&);
+    Performance(ScriptExecutionContext&, double timeOrigin);
 
     EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }
-    ScriptExecutionContext* scriptExecutionContext() const final;
 
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
@@ -104,7 +106,7 @@ private:
     Vector<RefPtr<PerformanceEntry>> m_resourceTimingBuffer;
     unsigned m_resourceTimingBufferSize { 150 };
 
-    double m_referenceTime;
+    double m_timeOrigin;
 
     std::unique_ptr<UserTiming> m_userTiming;
 
index aa9ddf3..1b384ed 100644 (file)
@@ -35,7 +35,7 @@ typedef double DOMHighResTimeStamp;
 
 [
     Conditional=WEB_TIMING,
-    GenerateIsReachable=ImplFrame,
+    GenerateIsReachable=ImplScriptExecutionContext,
 ] interface Performance : EventTarget {
 
     DOMHighResTimeStamp now();
index 6769e1d..2bed7d8 100644 (file)
 
 namespace WebCore {
 
-static double monotonicTimeToDocumentMilliseconds(Document* document, double seconds)
+static double monotonicTimeToDOMHighResTimeStamp(double timeOrigin, double seconds)
 {
     ASSERT(seconds >= 0.0);
-    return Performance::reduceTimeResolution(document->loader()->timing().monotonicTimeToZeroBasedDocumentTime(seconds)) * 1000.0;
+    if (!seconds || !timeOrigin)
+        return 0;
+    return Performance::reduceTimeResolution(seconds - timeOrigin) * 1000.0;
 }
 
-static bool passesTimingAllowCheck(const ResourceResponse& response, Document* requestingDocument)
+static bool passesTimingAllowCheck(const ResourceResponse& response, const SecurityOrigin& initiatorSecurityOrigin)
 {
     Ref<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url());
-    if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin()))
+    if (resourceOrigin->isSameSchemeHostPort(initiatorSecurityOrigin))
         return true;
 
     const String& timingAllowOriginString = response.httpHeaderField(HTTPHeaderName::TimingAllowOrigin);
@@ -64,7 +66,7 @@ static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r
     if (timingAllowOriginString == "*")
         return true;
 
-    const String& securityOrigin = requestingDocument->securityOrigin().toString();
+    const String& securityOrigin = initiatorSecurityOrigin.toString();
     Vector<String> timingAllowOrigins;
     timingAllowOriginString.split(' ', timingAllowOrigins);
     for (auto& origin : timingAllowOrigins) {
@@ -75,13 +77,13 @@ static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r
     return false;
 }
 
-PerformanceResourceTiming::PerformanceResourceTiming(const AtomicString& initiatorType, const URL& originalURL, const ResourceResponse& response, LoadTiming loadTiming, Document* requestingDocument)
-    : PerformanceEntry(PerformanceEntry::Type::Resource, originalURL.string(), ASCIILiteral("resource"), monotonicTimeToDocumentMilliseconds(requestingDocument, loadTiming.startTime()), monotonicTimeToDocumentMilliseconds(requestingDocument, loadTiming.responseEnd()))
+PerformanceResourceTiming::PerformanceResourceTiming(const AtomicString& initiatorType, const URL& originalURL, const ResourceResponse& response, const SecurityOrigin& initiatorSecurityOrigin, double timeOrigin, LoadTiming loadTiming)
+    : PerformanceEntry(PerformanceEntry::Type::Resource, originalURL.string(), ASCIILiteral("resource"), monotonicTimeToDOMHighResTimeStamp(timeOrigin, loadTiming.startTime()), monotonicTimeToDOMHighResTimeStamp(timeOrigin, loadTiming.responseEnd()))
     , m_initiatorType(initiatorType)
     , m_timing(response.networkLoadTiming())
     , m_loadTiming(loadTiming)
-    , m_shouldReportDetails(passesTimingAllowCheck(response, requestingDocument))
-    , m_requestingDocument(requestingDocument)
+    , m_shouldReportDetails(passesTimingAllowCheck(response, initiatorSecurityOrigin))
+    , m_timeOrigin(timeOrigin)
 {
 }
 
@@ -89,11 +91,6 @@ PerformanceResourceTiming::~PerformanceResourceTiming()
 {
 }
 
-AtomicString PerformanceResourceTiming::initiatorType() const
-{
-    return m_initiatorType;
-}
-
 double PerformanceResourceTiming::workerStart() const
 {
     return 0.0;
@@ -104,7 +101,7 @@ double PerformanceResourceTiming::redirectStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_loadTiming.redirectStart());
+    return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadTiming.redirectStart());
 }
 
 double PerformanceResourceTiming::redirectEnd() const
@@ -112,12 +109,12 @@ double PerformanceResourceTiming::redirectEnd() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_loadTiming.redirectEnd());
+    return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadTiming.redirectEnd());
 }
 
 double PerformanceResourceTiming::fetchStart() const
 {
-    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_loadTiming.fetchStart());
+    return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadTiming.fetchStart());
 }
 
 double PerformanceResourceTiming::domainLookupStart() const
@@ -128,7 +125,7 @@ double PerformanceResourceTiming::domainLookupStart() const
     if (m_timing.domainLookupStart <= 0)
         return fetchStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing.domainLookupStart);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.domainLookupStart);
 }
 
 double PerformanceResourceTiming::domainLookupEnd() const
@@ -139,7 +136,7 @@ double PerformanceResourceTiming::domainLookupEnd() const
     if (m_timing.domainLookupEnd <= 0)
         return domainLookupStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing.domainLookupEnd);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.domainLookupEnd);
 }
 
 double PerformanceResourceTiming::connectStart() const
@@ -156,7 +153,7 @@ double PerformanceResourceTiming::connectStart() const
     if (m_timing.domainLookupEnd >= 0)
         connectStart = m_timing.domainLookupEnd;
 
-    return resourceTimeToDocumentMilliseconds(connectStart);
+    return networkLoadTimeToDOMHighResTimeStamp(connectStart);
 }
 
 double PerformanceResourceTiming::connectEnd() const
@@ -168,7 +165,7 @@ double PerformanceResourceTiming::connectEnd() const
     if (m_timing.connectEnd <= 0)
         return connectStart();
 
-    return resourceTimeToDocumentMilliseconds(m_timing.connectEnd);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.connectEnd);
 }
 
 double PerformanceResourceTiming::secureConnectionStart() const
@@ -179,7 +176,7 @@ double PerformanceResourceTiming::secureConnectionStart() const
     if (m_timing.secureConnectionStart < 0) // Secure connection not negotiated.
         return 0.0;
 
-    return resourceTimeToDocumentMilliseconds(m_timing.secureConnectionStart);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.secureConnectionStart);
 }
 
 double PerformanceResourceTiming::requestStart() const
@@ -187,7 +184,7 @@ double PerformanceResourceTiming::requestStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    return resourceTimeToDocumentMilliseconds(m_timing.requestStart);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.requestStart);
 }
 
 double PerformanceResourceTiming::responseStart() const
@@ -195,7 +192,7 @@ double PerformanceResourceTiming::responseStart() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    return resourceTimeToDocumentMilliseconds(m_timing.responseStart);
+    return networkLoadTimeToDOMHighResTimeStamp(m_timing.responseStart);
 }
 
 double PerformanceResourceTiming::responseEnd() const
@@ -203,17 +200,16 @@ double PerformanceResourceTiming::responseEnd() const
     if (!m_shouldReportDetails)
         return 0.0;
 
-    return monotonicTimeToDocumentMilliseconds(m_requestingDocument.get(), m_loadTiming.responseEnd());
+    return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadTiming.responseEnd());
 }
 
-double PerformanceResourceTiming::resourceTimeToDocumentMilliseconds(double deltaMilliseconds) const
+double PerformanceResourceTiming::networkLoadTimeToDOMHighResTimeStamp(double deltaMilliseconds) const
 {
     if (!deltaMilliseconds)
         return 0.0;
 
-    double documentStartTime = m_requestingDocument->loader()->timing().monotonicTimeToZeroBasedDocumentTime(m_loadTiming.fetchStart()) * 1000.0;
-    double resourceTimeSeconds = (documentStartTime + deltaMilliseconds) / 1000.0;
-    return 1000.0 * Performance::reduceTimeResolution(resourceTimeSeconds);
+    double seconds = m_loadTiming.fetchStart() + (deltaMilliseconds / 1000.0);
+    return Performance::reduceTimeResolution(seconds - m_timeOrigin) * 1000.0;
 }
 
 } // namespace WebCore
index 74ff82a..094ebef 100644 (file)
 
 namespace WebCore {
 
-class Document;
-class URL;
-class NetworkLoadTiming;
 class ResourceResponse;
+class SecurityOrigin;
+class URL;
 
 class PerformanceResourceTiming final : public PerformanceEntry {
 public:
-    static Ref<PerformanceResourceTiming> create(const AtomicString& initiatorType, const URL& originalURL, const ResourceResponse& response, LoadTiming loadTiming, Document* requestingDocument)
+    static Ref<PerformanceResourceTiming> create(const AtomicString& initiatorType, const URL& originalURL, const ResourceResponse& response, const SecurityOrigin& initiatorSecurityOrigin, double timeOrigin, LoadTiming loadTiming)
     {
-        return adoptRef(*new PerformanceResourceTiming(initiatorType, originalURL, response, loadTiming, requestingDocument));
+        return adoptRef(*new PerformanceResourceTiming(initiatorType, originalURL, response, initiatorSecurityOrigin, timeOrigin, loadTiming));
     }
 
-    AtomicString initiatorType() const;
+    AtomicString initiatorType() const { return m_initiatorType; }
 
     double workerStart() const;
     double redirectStart() const;
@@ -71,16 +70,16 @@ public:
     bool isResource() const override { return true; }
 
 private:
-    PerformanceResourceTiming(const AtomicString& initatorType, const URL& originalURL, const ResourceResponse&, LoadTiming, Document*);
+    PerformanceResourceTiming(const AtomicString& initatorType, const URL& originalURL, const ResourceResponse&, const SecurityOrigin&, double timeOrigin, LoadTiming);
     ~PerformanceResourceTiming();
 
-    double resourceTimeToDocumentMilliseconds(double deltaMilliseconds) const;
+    double networkLoadTimeToDOMHighResTimeStamp(double deltaMilliseconds) const;
 
     AtomicString m_initiatorType;
     NetworkLoadTiming m_timing;
     LoadTiming m_loadTiming;
     bool m_shouldReportDetails;
-    RefPtr<Document> m_requestingDocument;
+    double m_timeOrigin;
 };
 
 } // namespace WebCore
index 7b9400d..dcb057a 100644 (file)
@@ -117,10 +117,16 @@ ExceptionOr<double> UserTiming::findExistingMarkStartTime(const String& markName
         return m_marksMap.get(markName).last()->startTime();
 
     if (auto function = restrictedMarkFunction(markName)) {
-        double value = static_cast<double>((m_performance.timing().*(function))());
-        if (!value)
-            return Exception { INVALID_ACCESS_ERR };
-        return value - m_performance.timing().navigationStart();
+        if (PerformanceTiming* timing = m_performance.timing()) {
+            double value = static_cast<double>(((*timing).*(function))());
+            if (!value)
+                return Exception { INVALID_ACCESS_ERR };
+            return value - timing->navigationStart();
+        } else {
+            // FIXME: Support UserTiming in Workers.
+            ASSERT_NOT_REACHED();
+            return Exception { SYNTAX_ERR };
+        }
     }
 
     return Exception { SYNTAX_ERR };