diff --git a/dom/base/WebSocket.cpp b/dom/base/WebSocket.cpp index 1ae6ebf2f1b..418afea439f 100644 --- a/dom/base/WebSocket.cpp +++ b/dom/base/WebSocket.cpp @@ -2523,6 +2523,9 @@ public: bool PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) { + // We don't call WorkerRunnable::PreDispatch because it would assert the + // wrong thing about which thread we're on. + AssertIsOnMainThread(); return true; } @@ -2530,6 +2533,9 @@ public: PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aDispatchResult) { + // We don't call WorkerRunnable::PostDispatch because it would assert the + // wrong thing about which thread we're on. + AssertIsOnMainThread(); } private: @@ -2696,6 +2702,10 @@ public: bool PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) { + // We don't call WorkerRunnable::PreDispatch because it would assert the + // wrong thing about which thread we're on. We're on whichever thread the + // channel implementation is running on (probably the main thread or socket + // transport thread). return true; } @@ -2703,6 +2713,10 @@ public: PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aDispatchResult) { + // We don't call WorkerRunnable::PreDispatch because it would assert the + // wrong thing about which thread we're on. We're on whichever thread the + // channel implementation is running on (probably the main thread or socket + // transport thread). } private: diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index e68e510c7af..b81b387aa0f 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -375,6 +375,9 @@ protected: bool PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override { + // We don't call WorkerRunnable::PreDispatch because it would assert the + // wrong thing about which thread we're on. + AssertIsOnMainThread(); return true; } @@ -382,6 +385,9 @@ protected: PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override { + // We don't call WorkerRunnable::PostDispatch because it would assert the + // wrong thing about which thread we're on. + AssertIsOnMainThread(); } bool diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp index 54a169bac80..578c985903c 100644 --- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -319,6 +319,8 @@ public: nsCOMPtr runnable = new RegistrationUpdateRunnable(mRegistration, true /* time check */); NS_DispatchToMainThread(runnable.forget()); + + ExtendableEventWorkerRunnable::PostRun(aCx, aWorkerPrivate, aRunResult); } }; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 848de8e9c80..151c5270694 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -610,9 +610,7 @@ private: WorkerRunnable::PostRun(aCx, aWorkerPrivate, aRunResult); // Match the busy count increase from NotifyRunnable. - if (!aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false)) { - JS_ReportPendingException(aCx); - } + aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false); aWorkerPrivate->CloseHandlerFinished(); } diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp index 416f7eb46a2..952a4d83f89 100644 --- a/dom/workers/WorkerRunnable.cpp +++ b/dom/workers/WorkerRunnable.cpp @@ -223,9 +223,7 @@ WorkerRunnable::PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, #endif if (mBehavior == WorkerThreadModifyBusyCount) { - if (!aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false)) { - aRunResult = false; - } + aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false); } if (!aRunResult) { @@ -644,6 +642,9 @@ bool WorkerSameThreadRunnable::PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) { + // We don't call WorkerRunnable::PreDispatch, because we're using + // WorkerThreadModifyBusyCount for mBehavior, and WorkerRunnable will assert + // that PreDispatch is on the parent thread in that case. aWorkerPrivate->AssertIsOnWorkerThread(); return true; } @@ -653,6 +654,9 @@ WorkerSameThreadRunnable::PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aDispatchResult) { + // We don't call WorkerRunnable::PostDispatch, because we're using + // WorkerThreadModifyBusyCount for mBehavior, and WorkerRunnable will assert + // that PostDispatch is on the parent thread in that case. aWorkerPrivate->AssertIsOnWorkerThread(); if (aDispatchResult) { DebugOnly willIncrement = aWorkerPrivate->ModifyBusyCountFromWorker(aCx, true); @@ -661,21 +665,3 @@ WorkerSameThreadRunnable::PostDispatch(JSContext* aCx, MOZ_ASSERT(willIncrement); } } - -void -WorkerSameThreadRunnable::PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, - bool aRunResult) -{ - MOZ_ASSERT(aCx); - MOZ_ASSERT(aWorkerPrivate); - - aWorkerPrivate->AssertIsOnWorkerThread(); - - DebugOnly willDecrement = aWorkerPrivate->ModifyBusyCountFromWorker(aCx, false); - MOZ_ASSERT(willDecrement); - - if (!aRunResult) { - JS_ReportPendingException(aCx); - } -} - diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h index a26181634de..62bfb7a051f 100644 --- a/dom/workers/WorkerRunnable.h +++ b/dom/workers/WorkerRunnable.h @@ -405,9 +405,8 @@ protected: PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override; - virtual void - PostRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate, - bool aRunResult) override; + // We just delegate PostRun to WorkerRunnable, since it does exactly + // what we want. }; // Base class for the runnable objects, which makes a synchronous call to