Bug 1322292 - Some fixes for the Performance API in workers - part 2 - Get rid of NowBaseTimeStamp(), r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 16 Dec 2016 09:07:39 +0100
changeset 371146 301231f4165a6f6a5f053c10b5d6d7a0895a0888
parent 371145 291a68ca482551e80a3eecbcb0ec1a65dcb00378
child 371147 b827e4d0dc73177846ac66e422b77f645cde5895
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1322292
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1322292 - Some fixes for the Performance API in workers - part 2 - Get rid of NowBaseTimeStamp(), r=bz
dom/console/Console.cpp
dom/console/Console.h
dom/events/Event.cpp
dom/performance/PerformanceMainThread.cpp
dom/performance/PerformanceWorker.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -1331,17 +1331,17 @@ Console::MethodInternal(JSContext* aCx, 
           }
         }
       }
     } else {
       WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
       MOZ_ASSERT(workerPrivate);
 
       TimeDuration duration =
-        mozilla::TimeStamp::Now() - workerPrivate->NowBaseTimeStamp();
+        mozilla::TimeStamp::Now() - workerPrivate->CreationTimeStamp();
 
       monotonicTimer = duration.ToMilliseconds();
     }
   }
 
   if (aMethodName == MethodTime && !aData.IsEmpty()) {
     callData->mStartTimerStatus = StartTimer(aCx, aData[0],
                                              monotonicTimer,
--- a/dom/console/Console.h
+++ b/dom/console/Console.h
@@ -253,19 +253,18 @@ private:
   ComposeGroupName(JSContext* aCx, const Sequence<JS::Value>& aData,
                    nsAString& aName) const;
 
   // StartTimer is called on the owning thread and populates aTimerLabel and
   // aTimerValue. It returns false if a JS exception is thrown or if
   // the max number of timers is reached.
   // * aCx - the JSContext rooting aName.
   // * aName - this is (should be) the name of the timer as JS::Value.
-  // * aTimestamp - the monotonicTimer for this context (taken from
-  //                window->performance.now() or from Now() -
-  //                workerPrivate->NowBaseTimeStamp() in workers.
+  // * aTimestamp - the monotonicTimer for this context taken from
+  //                performance.now().
   // * aTimerLabel - This label will be populated with the aName converted to a
   //                 string.
   // * aTimerValue - the StartTimer value stored into (or taken from)
   //                 mTimerRegistry.
   bool
   StartTimer(JSContext* aCx, const JS::Value& aName,
              DOMHighResTimeStamp aTimestamp,
              nsAString& aTimerLabel,
@@ -285,19 +284,18 @@ private:
                         bool aTimerStatus) const;
 
   // StopTimer follows the same pattern as StartTimer: it runs on the
   // owning thread and populates aTimerLabel and aTimerDuration, used by
   // CreateStopTimerValue. It returns false if a JS exception is thrown or if
   // the aName timer doesn't exist in the mTimerRegistry.
   // * aCx - the JSContext rooting aName.
   // * aName - this is (should be) the name of the timer as JS::Value.
-  // * aTimestamp - the monotonicTimer for this context (taken from
-  //                window->performance.now() or from Now() -
-  //                workerPrivate->NowBaseTimeStamp() in workers.
+  // * aTimestamp - the monotonicTimer for this context taken from
+  //                performance.now().
   // * aTimerLabel - This label will be populated with the aName converted to a
   //                 string.
   // * aTimerDuration - the difference between aTimestamp and when the timer
   //                    started (see StartTimer).
   bool
   StopTimer(JSContext* aCx, const JS::Value& aName,
             DOMHighResTimeStamp aTimestamp,
             nsAString& aTimerLabel,
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -1089,25 +1089,24 @@ Event::TimeStamp() const
     Performance* perf = win->GetPerformance();
     if (NS_WARN_IF(!perf)) {
       return 0.0;
     }
 
     return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
   }
 
-  // For dedicated workers, we should make times relative to the navigation
-  // start of the document that created the worker, which is the same as the
-  // timebase for performance.now().
+  // For dedicated workers, we should make times relative to the creation time
+  // of the worker, which is the same as the timebase for performance.now().
   workers::WorkerPrivate* workerPrivate =
     workers::GetCurrentThreadWorkerPrivate();
   MOZ_ASSERT(workerPrivate);
 
   TimeDuration duration =
-    mEvent->mTimeStamp - workerPrivate->NowBaseTimeStamp();
+    mEvent->mTimeStamp - workerPrivate->CreationTimeStamp();
   return duration.ToMilliseconds();
 }
 
 bool
 Event::GetPreventDefault() const
 {
   nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(mOwner));
   if (win) {
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -70,17 +70,17 @@ PerformanceMainThread::GetMozMemory(JSCo
 
   aObj.set(mMozMemory);
 }
 
 PerformanceTiming*
 PerformanceMainThread::Timing()
 {
   if (!mTiming) {
-    // For navigation timing, the third argument (an nsIHtttpChannel) is null
+    // For navigation timing, the third argument (an nsIHttpChannel) is null
     // since the cross-domain redirect were already checked.  The last argument
     // (zero time) for performance.timing is the navigation start value.
     mTiming = new PerformanceTiming(this, mChannel, nullptr,
                                     mDOMTiming->GetNavigationStart());
   }
 
   return mTiming;
 }
--- a/dom/performance/PerformanceWorker.cpp
+++ b/dom/performance/PerformanceWorker.cpp
@@ -34,17 +34,17 @@ PerformanceWorker::IsPerformanceTimingAt
 DOMHighResTimeStamp
 PerformanceWorker::GetPerformanceTimingFromString(const nsAString& aProperty)
 {
   if (!IsPerformanceTimingAttribute(aProperty)) {
     return 0;
   }
 
   if (aProperty.EqualsLiteral("navigationStart")) {
-    return mWorkerPrivate->NowBaseTime();
+    return mWorkerPrivate->CreationTime();
   }
 
   MOZ_CRASH("IsPerformanceTimingAttribute and GetPerformanceTimingFromString are out of sync");
   return 0;
 }
 
 void
 PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
@@ -59,19 +59,19 @@ PerformanceWorker::InsertUserEntry(Perfo
     Performance::LogEntry(aEntry, uri);
   }
   Performance::InsertUserEntry(aEntry);
 }
 
 TimeStamp
 PerformanceWorker::CreationTimeStamp() const
 {
-  return mWorkerPrivate->NowBaseTimeStamp();
+  return mWorkerPrivate->CreationTimeStamp();
 }
 
 DOMHighResTimeStamp
 PerformanceWorker::CreationTime() const
 {
-  return mWorkerPrivate->NowBaseTime();
+  return mWorkerPrivate->CreationTime();
 }
 
 } // dom namespace
 } // mozilla namespace
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2294,18 +2294,16 @@ WorkerPrivateParent<Derived>::WorkerPriv
     aParent->CopyJSSettings(mJSSettings);
 
     // And manually set our mIsSecureContext, though it's not really relevant to
     // dedicated workers...
     mIsSecureContext = aParent->IsSecureContext();
     MOZ_ASSERT_IF(mIsChromeWorker, mIsSecureContext);
 
     MOZ_ASSERT(IsDedicatedWorker());
-    mNowBaseTimeStamp = aParent->NowBaseTimeStamp();
-    mNowBaseTimeHighRes = aParent->NowBaseTime();
 
     if (aParent->mParentFrozen) {
       Freeze(nullptr);
     }
   }
   else {
     AssertIsOnMainThread();
 
@@ -2326,28 +2324,16 @@ WorkerPrivateParent<Derived>::WorkerPriv
 
     if (mIsSecureContext) {
       mJSSettings.chrome.compartmentOptions
                  .creationOptions().setSecureContext(true);
       mJSSettings.content.compartmentOptions
                  .creationOptions().setSecureContext(true);
     }
 
-    if (IsDedicatedWorker() && mLoadInfo.mWindow &&
-        mLoadInfo.mWindow->GetPerformance()) {
-      mNowBaseTimeStamp = mLoadInfo.mWindow->GetPerformance()->GetDOMTiming()->
-        GetNavigationStartTimeStamp();
-      mNowBaseTimeHighRes =
-      mLoadInfo.mWindow->GetPerformance()->GetDOMTiming()->
-        GetNavigationStartHighRes();
-    } else {
-      mNowBaseTimeStamp = CreationTimeStamp();
-      mNowBaseTimeHighRes = CreationTime();
-    }
-
     // Our parent can get suspended after it initiates the async creation
     // of a new worker thread.  In this case suspend the new worker as well.
     if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsSuspended()) {
       ParentWindowPaused();
     }
 
     if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsFrozen()) {
       Freeze(mLoadInfo.mWindow);
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -211,18 +211,16 @@ private:
   //
   // It's a bit unfortunate that we have to have an out-of-band boolean for
   // this, but we need access to this state from the parent thread, and we can't
   // use our global object's secure state there.
   bool mIsSecureContext;
   WorkerType mWorkerType;
   TimeStamp mCreationTimeStamp;
   DOMHighResTimeStamp mCreationTimeHighRes;
-  TimeStamp mNowBaseTimeStamp;
-  DOMHighResTimeStamp mNowBaseTimeHighRes;
 
 protected:
   // The worker is owned by its thread, which is represented here.  This is set
   // in Construct() and emptied by WorkerFinishedRunnable, and conditionally
   // traversed by the cycle collector if the busy count is zero.
   RefPtr<WorkerPrivate> mSelfRef;
 
   WorkerPrivateParent(WorkerPrivate* aParent,
@@ -569,26 +567,16 @@ public:
     return mCreationTimeStamp;
   }
 
   DOMHighResTimeStamp CreationTime() const
   {
     return mCreationTimeHighRes;
   }
 
-  TimeStamp NowBaseTimeStamp() const
-  {
-    return mNowBaseTimeStamp;
-  }
-
-  DOMHighResTimeStamp NowBaseTime() const
-  {
-    return mNowBaseTimeHighRes;
-  }
-
   nsIPrincipal*
   GetPrincipal() const
   {
     AssertIsOnMainThread();
     return mLoadInfo.mPrincipal;
   }
 
   nsILoadGroup*