diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index b3cb3c7f61e8..f4d32723d3e1 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -3622,7 +3622,7 @@ private: } void - RunBackOnWorkerThread() override + RunBackOnWorkerThreadForCleanup() override {} }; diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index 566abd53c2fb..d21e16842899 100644 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -337,12 +337,12 @@ public: mWorkerPrivate->AssertIsOnWorkerThread(); if (NS_WARN_IF(!PreDispatch(aCx))) { - RunBackOnWorkerThread(); + RunBackOnWorkerThreadForCleanup(); return false; } if (NS_WARN_IF(!WorkerProxyToMainThreadRunnable::Dispatch())) { - // RunBackOnWorkerThread() will be called by + // RunBackOnWorkerThreadForCleanup() will be called by // WorkerProxyToMainThreadRunnable::Dispatch(). return false; } @@ -421,7 +421,7 @@ protected: } void - RunBackOnWorkerThread() override + RunBackOnWorkerThreadForCleanup() override { mWorkerPrivate->AssertIsOnWorkerThread(); ReleaseData(); diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp index 2fac0ef9e604..fd998b24e7e1 100644 --- a/dom/workers/WorkerRunnable.cpp +++ b/dom/workers/WorkerRunnable.cpp @@ -677,13 +677,13 @@ WorkerProxyToMainThreadRunnable::Dispatch() mWorkerPrivate->AssertIsOnWorkerThread(); if (NS_WARN_IF(!HoldWorker())) { - RunBackOnWorkerThread(); + RunBackOnWorkerThreadForCleanup(); return false; } if (NS_WARN_IF(NS_FAILED(mWorkerPrivate->DispatchToMainThread(this)))) { ReleaseWorker(); - RunBackOnWorkerThread(); + RunBackOnWorkerThreadForCleanup(); return false; } @@ -715,7 +715,8 @@ WorkerProxyToMainThreadRunnable::PostDispatchOnMainThread() MOZ_ASSERT(aRunnable); } - // We must call RunBackOnWorkerThread() also if the runnable is canceled. + // We must call RunBackOnWorkerThreadForCleanup() also if the runnable is + // canceled. nsresult Cancel() override { @@ -730,7 +731,7 @@ WorkerProxyToMainThreadRunnable::PostDispatchOnMainThread() aWorkerPrivate->AssertIsOnWorkerThread(); if (mRunnable) { - mRunnable->RunBackOnWorkerThread(); + mRunnable->RunBackOnWorkerThreadForCleanup(); // Let's release the worker thread. mRunnable->ReleaseWorker(); diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h index 8249a8053e34..7a36f663f578 100644 --- a/dom/workers/WorkerRunnable.h +++ b/dom/workers/WorkerRunnable.h @@ -415,6 +415,12 @@ private: // This runnable is an helper class for dispatching something from a worker // thread to the main-thread and back to the worker-thread. During this // operation, this class will keep the worker alive. +// The purpose of RunBackOnWorkerThreadForCleanup() must be used, as the name +// says, only to release resources, no JS has to be executed, no timers, or +// other things. The reason of such limitations is that, in order to execute +// this method in any condition (also when the worker is shutting down), a +// Control Runnable is used, and, this could generate a reordering of existing +// runnables. class WorkerProxyToMainThreadRunnable : public Runnable { protected: @@ -426,7 +432,7 @@ protected: virtual void RunOnMainThread() = 0; // After this second method is called on the worker-thread. - virtual void RunBackOnWorkerThread() = 0; + virtual void RunBackOnWorkerThreadForCleanup() = 0; public: bool Dispatch();