Bug 1403926 - Make the PerformanceNavigationTiming timestamps be relative to startTime r=baku draft
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 04 Oct 2017 02:48:36 +0200
changeset 674571 bc4b7fa0526a3fe749c17ce10f70baa8a33f8bb1
parent 674570 0a1252a7cff2cfaec8f0ab5f8ffa755a0a8a4b5e
child 674572 1c8b29a9cc0aec9e33dadbea8808dfda9f9a6888
push id82894
push uservalentin.gosu@gmail.com
push dateWed, 04 Oct 2017 02:08:48 +0000
reviewersbaku
bugs1403926
milestone58.0a1
Bug 1403926 - Make the PerformanceNavigationTiming timestamps be relative to startTime r=baku MozReview-Commit-ID: 7lvSsde9dzh
dom/performance/PerformanceMainThread.cpp
dom/performance/PerformanceNavigationTiming.h
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -309,17 +309,19 @@ PerformanceMainThread::CreationTime() co
   return GetDOMTiming()->GetNavigationStart();
 }
 
 void
 PerformanceMainThread::EnsureDocEntry()
 {
   if (!mDocEntry && nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
-    mDocEntry = new PerformanceNavigationTiming(Timing(), this,
+    RefPtr<PerformanceTiming> timing =
+      new PerformanceTiming(this, mChannel, nullptr, 0);
+    mDocEntry = new PerformanceNavigationTiming(timing, this,
                                                 httpChannel);
   }
 }
 
 
 void
 PerformanceMainThread::GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval)
 {
--- a/dom/performance/PerformanceNavigationTiming.h
+++ b/dom/performance/PerformanceNavigationTiming.h
@@ -19,16 +19,20 @@ namespace dom {
 
 // https://www.w3.org/TR/navigation-timing-2/#sec-PerformanceNavigationTiming
 class PerformanceNavigationTiming final
   : public PerformanceResourceTiming
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
+  // Note that aPerformanceTiming must be initalized with zeroTime = 0
+  // so that timestamps are relative to startTime, as opposed to the
+  // performance.timing object for which timestamps are absolute and has a
+  // zeroTime initialized to navigationStart
   explicit PerformanceNavigationTiming(PerformanceTiming* aPerformanceTiming,
                                        Performance* aPerformance,
                                        nsIHttpChannel* aChannel)
     : PerformanceResourceTiming(aPerformanceTiming, aPerformance,
                                 NS_LITERAL_STRING("document"), aChannel) {
       SetEntryType(NS_LITERAL_STRING("navigation"));
       SetInitiatorType(NS_LITERAL_STRING("navigation"));
     }