diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-07-05 22:22:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-05 22:22:47 +0200 |
commit | c3fe7f59c8b6c1a23f5ae85f0697470fad560d68 (patch) | |
tree | 93fb783c7d463225be63f76102bddec19965bc93 /dom/workers/WorkerPrivate.h | |
parent | 06ccf0f73ade5b436d2e7e00f81db7aebf7960cf (diff) | |
parent | a80267e9e88b3dcebf7f8f1f6f10931a99ddf2ca (diff) | |
download | UXP-c3fe7f59c8b6c1a23f5ae85f0697470fad560d68.tar UXP-c3fe7f59c8b6c1a23f5ae85f0697470fad560d68.tar.gz UXP-c3fe7f59c8b6c1a23f5ae85f0697470fad560d68.tar.lz UXP-c3fe7f59c8b6c1a23f5ae85f0697470fad560d68.tar.xz UXP-c3fe7f59c8b6c1a23f5ae85f0697470fad560d68.zip |
Merge pull request #597 from janekptacijarabaci/dom_workers_terminate_1
Sync event loops in workers should be created only if compatible with the worker shutdown status
Diffstat (limited to 'dom/workers/WorkerPrivate.h')
-rw-r--r-- | dom/workers/WorkerPrivate.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 28283bed7..20a530205 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -1442,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(); @@ -1518,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(); @@ -1528,7 +1533,7 @@ public: ~AutoSyncLoopHolder() { - if (mWorkerPrivate) { + if (mWorkerPrivate && mTarget) { mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate->StopSyncLoop(mTarget, false); mWorkerPrivate->DestroySyncLoop(mIndex); @@ -1547,8 +1552,9 @@ public: } nsIEventTarget* - EventTarget() const + GetEventTarget() const { + // This can be null if CreateNewSyncLoop() fails. return mTarget; } }; |