Bug 1322292 - Some fixes for the Performance API in workers - part 2 - Get rid of NowBaseTimeStamp()

https://hg.mozilla.org/mozilla-central/rev/301231f4165a
This commit is contained in:
janekptacijarabaci 2018-04-29 12:32:19 +02:00 • committed by Roy Tam
commit c1d7159d0f
7 changed files with 11 additions and 40 deletions

View file

@ -1337,7 +1337,7 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
TimeDuration duration = TimeDuration duration =
mozilla::TimeStamp::Now() - workerPrivate->NowBaseTimeStamp(); mozilla::TimeStamp::Now() - workerPrivate->CreationTimeStamp();
monotonicTimer = TimerClamping::ReduceMsTimeValue(duration.ToMilliseconds()); monotonicTimer = TimerClamping::ReduceMsTimeValue(duration.ToMilliseconds());
} }

View file

@ -258,9 +258,8 @@ private:
// the max number of timers is reached. // the max number of timers is reached.
// * aCx - the JSContext rooting aName. // * aCx - the JSContext rooting aName.
// * aName - this is (should be) the name of the timer as JS::Value. // * aName - this is (should be) the name of the timer as JS::Value.
// * aTimestamp - the monotonicTimer for this context (taken from // * aTimestamp - the monotonicTimer for this context taken from
// window->performance.now() or from Now() - // performance.now().
// workerPrivate->NowBaseTimeStamp() in workers.
// * aTimerLabel - This label will be populated with the aName converted to a // * aTimerLabel - This label will be populated with the aName converted to a
// string. // string.
// * aTimerValue - the StartTimer value stored into (or taken from) // * aTimerValue - the StartTimer value stored into (or taken from)
@ -290,9 +289,8 @@ private:
// the aName timer doesn't exist in the mTimerRegistry. // the aName timer doesn't exist in the mTimerRegistry.
// * aCx - the JSContext rooting aName. // * aCx - the JSContext rooting aName.
// * aName - this is (should be) the name of the timer as JS::Value. // * aName - this is (should be) the name of the timer as JS::Value.
// * aTimestamp - the monotonicTimer for this context (taken from // * aTimestamp - the monotonicTimer for this context taken from
// window->performance.now() or from Now() - // performance.now().
// workerPrivate->NowBaseTimeStamp() in workers.
// * aTimerLabel - This label will be populated with the aName converted to a // * aTimerLabel - This label will be populated with the aName converted to a
// string. // string.
// * aTimerDuration - the difference between aTimestamp and when the timer // * aTimerDuration - the difference between aTimestamp and when the timer

View file

@ -1146,15 +1146,14 @@ Event::TimeStampImpl() const
return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp); return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp);
} }
// For dedicated workers, we should make times relative to the navigation // For dedicated workers, we should make times relative to the creation time
// start of the document that created the worker, which is the same as the // of the worker, which is the same as the timebase for performance.now().
// timebase for performance.now().
workers::WorkerPrivate* workerPrivate = workers::WorkerPrivate* workerPrivate =
workers::GetCurrentThreadWorkerPrivate(); workers::GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
TimeDuration duration = TimeDuration duration =
mEvent->mTimeStamp - workerPrivate->NowBaseTimeStamp(); mEvent->mTimeStamp - workerPrivate->CreationTimeStamp();
return duration.ToMilliseconds(); return duration.ToMilliseconds();
} }

View file

@ -75,7 +75,7 @@ PerformanceTiming*
PerformanceMainThread::Timing() PerformanceMainThread::Timing()
{ {
if (!mTiming) { 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 // since the cross-domain redirect were already checked. The last argument
// (zero time) for performance.timing is the navigation start value. // (zero time) for performance.timing is the navigation start value.
mTiming = new PerformanceTiming(this, mChannel, nullptr, mTiming = new PerformanceTiming(this, mChannel, nullptr,

View file

@ -41,13 +41,13 @@ PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
TimeStamp TimeStamp
PerformanceWorker::CreationTimeStamp() const PerformanceWorker::CreationTimeStamp() const
{ {
return mWorkerPrivate->NowBaseTimeStamp(); return mWorkerPrivate->CreationTimeStamp();
} }
DOMHighResTimeStamp DOMHighResTimeStamp
PerformanceWorker::CreationTime() const PerformanceWorker::CreationTime() const
{ {
return mWorkerPrivate->NowBaseTime(); return mWorkerPrivate->CreationTime();
} }
} // dom namespace } // dom namespace

View file

@ -2419,8 +2419,6 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
MOZ_ASSERT_IF(mIsChromeWorker, mIsSecureContext); MOZ_ASSERT_IF(mIsChromeWorker, mIsSecureContext);
MOZ_ASSERT(IsDedicatedWorker()); MOZ_ASSERT(IsDedicatedWorker());
mNowBaseTimeStamp = aParent->NowBaseTimeStamp();
mNowBaseTimeHighRes = aParent->NowBaseTime();
if (aParent->mParentFrozen) { if (aParent->mParentFrozen) {
Freeze(nullptr); Freeze(nullptr);
@ -2451,18 +2449,6 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
.creationOptions().setSecureContext(true); .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 // 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. // of a new worker thread. In this case suspend the new worker as well.
if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsSuspended()) { if (mLoadInfo.mWindow && mLoadInfo.mWindow->IsSuspended()) {

View file

@ -216,8 +216,6 @@ private:
WorkerType mWorkerType; WorkerType mWorkerType;
TimeStamp mCreationTimeStamp; TimeStamp mCreationTimeStamp;
DOMHighResTimeStamp mCreationTimeHighRes; DOMHighResTimeStamp mCreationTimeHighRes;
TimeStamp mNowBaseTimeStamp;
DOMHighResTimeStamp mNowBaseTimeHighRes;
protected: protected:
// The worker is owned by its thread, which is represented here. This is set // The worker is owned by its thread, which is represented here. This is set
@ -579,16 +577,6 @@ public:
return mCreationTimeHighRes; return mCreationTimeHighRes;
} }
TimeStamp NowBaseTimeStamp() const
{
return mNowBaseTimeStamp;
}
DOMHighResTimeStamp NowBaseTime() const
{
return mNowBaseTimeHighRes;
}
nsIPrincipal* nsIPrincipal*
GetPrincipal() const GetPrincipal() const
{ {