summaryrefslogtreecommitdiffstats
path: root/dom/workers/WorkerPrivate.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/workers/WorkerPrivate.h')
-rw-r--r--dom/workers/WorkerPrivate.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
index 465c0f9a3..20a530205 100644
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -216,8 +216,6 @@ private:
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
@@ -579,14 +577,11 @@ public:
return mCreationTimeHighRes;
}
- TimeStamp NowBaseTimeStamp() const
+ DOMHighResTimeStamp TimeStampToDOMHighRes(const TimeStamp& aTimeStamp) const
{
- return mNowBaseTimeStamp;
- }
-
- DOMHighResTimeStamp NowBaseTime() const
- {
- return mNowBaseTimeHighRes;
+ MOZ_ASSERT(!aTimeStamp.IsNull());
+ TimeDuration duration = aTimeStamp - mCreationTimeStamp;
+ return duration.ToMilliseconds();
}
nsIPrincipal*
@@ -1447,8 +1442,11 @@ private:
memcpy(aPreferences, mPreferences, WORKERPREF_COUNT * sizeof(bool));
}
+ // If the worker shutdown status is equal or greater then aFailStatus, this
+ // operation will fail and nullptr will be returned. See WorkerHolder.h for
+ // more information about the correct value to use.
already_AddRefed<nsIEventTarget>
- CreateNewSyncLoop();
+ CreateNewSyncLoop(Status aFailStatus);
bool
RunCurrentSyncLoop();
@@ -1523,9 +1521,11 @@ class AutoSyncLoopHolder
uint32_t mIndex;
public:
- explicit AutoSyncLoopHolder(WorkerPrivate* aWorkerPrivate)
+ // See CreateNewSyncLoop() for more information about the correct value to use
+ // for aFailStatus.
+ AutoSyncLoopHolder(WorkerPrivate* aWorkerPrivate, Status aFailStatus)
: mWorkerPrivate(aWorkerPrivate)
- , mTarget(aWorkerPrivate->CreateNewSyncLoop())
+ , mTarget(aWorkerPrivate->CreateNewSyncLoop(aFailStatus))
, mIndex(aWorkerPrivate->mSyncLoopStack.Length() - 1)
{
aWorkerPrivate->AssertIsOnWorkerThread();
@@ -1533,7 +1533,7 @@ public:
~AutoSyncLoopHolder()
{
- if (mWorkerPrivate) {
+ if (mWorkerPrivate && mTarget) {
mWorkerPrivate->AssertIsOnWorkerThread();
mWorkerPrivate->StopSyncLoop(mTarget, false);
mWorkerPrivate->DestroySyncLoop(mIndex);
@@ -1552,8 +1552,9 @@ public:
}
nsIEventTarget*
- EventTarget() const
+ GetEventTarget() const
{
+ // This can be null if CreateNewSyncLoop() fails.
return mTarget;
}
};