Record the reference time when Performance is constructed.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 May 2015 04:49:00 +0000 (04:49 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 May 2015 04:49:00 +0000 (04:49 +0000)
<https://webkit.org/b/144616>

Reviewed by Geoffrey Garen.

This is a merge of Blink's r156613 by simonjam@chromium.org.

Cache a copy of the DocumentLoader's reference timestamp when constructing
the Performance object. That way we don't have to jump through a bunch of scary
hoops to access it when now() is called later on.

* page/Performance.cpp:
(WebCore::Performance::Performance):
(WebCore::Performance::now): Deleted.
* page/Performance.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoadTiming.h
Source/WebCore/page/Performance.cpp
Source/WebCore/page/Performance.h

index ad2e316..68f01d4 100644 (file)
@@ -1,3 +1,21 @@
+2015-05-04  Andreas Kling  <akling@apple.com>
+
+        Record the reference time when Performance is constructed.
+        <https://webkit.org/b/144616>
+
+        Reviewed by Geoffrey Garen.
+
+        This is a merge of Blink's r156613 by simonjam@chromium.org.
+
+        Cache a copy of the DocumentLoader's reference timestamp when constructing
+        the Performance object. That way we don't have to jump through a bunch of scary
+        hoops to access it when now() is called later on.
+
+        * page/Performance.cpp:
+        (WebCore::Performance::Performance):
+        (WebCore::Performance::now): Deleted.
+        * page/Performance.h:
+
 2015-05-04  Simon Fraser  <simon.fraser@apple.com>
 
         Fix assertions in WK1 tests after r183777.
index f87691e..1904a7a 100644 (file)
@@ -67,6 +67,8 @@ public:
     bool hasCrossOriginRedirect() const { return m_hasCrossOriginRedirect; }
     bool hasSameOriginAsPreviousDocument() const { return m_hasSameOriginAsPreviousDocument; }
 
+    double referenceMonotonicTime() const { return m_referenceMonotonicTime; }
+
 private:
     double m_referenceMonotonicTime;
     double m_referenceWallTime;
index 62f3766..07de431 100644 (file)
@@ -60,7 +60,9 @@ Performance::Performance(Frame* frame)
 #if ENABLE(USER_TIMING)
     , m_userTiming(0)
 #endif // ENABLE(USER_TIMING)
+    , m_referenceTime(frame->document()->loader()->timing().referenceMonotonicTime())
 {
+    ASSERT(m_referenceTime);
 }
 
 Performance::~Performance()
@@ -228,10 +230,7 @@ void Performance::webkitClearMeasures(const String& measureName)
 
 double Performance::now() const
 {
-    if (!frame())
-        return 0;
-
-    return 1000.0 * m_frame->document()->loader()->timing().monotonicTimeToZeroBasedDocumentTime(monotonicallyIncreasingTime());
+    return 1000.0 * (WTF::monotonicallyIncreasingTime() - m_referenceTime);
 }
 
 } // namespace WebCore
index e060c5d..76e49b4 100644 (file)
@@ -103,6 +103,8 @@ private:
     unsigned m_resourceTimingBufferSize;
 #endif
 
+    double m_referenceTime;
+
 #if ENABLE(USER_TIMING)
     RefPtr<UserTiming> m_userTiming;
 #endif // ENABLE(USER_TIMING)