Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/WebKit/Source/core/workers/WorkerThread.cpp

Issue 2339983003: Worker: Check whether forcible termination happened before processing a task (Closed)
Patch Set: remove prepareForShutdown call from didProcessTask Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/WorkerThread.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerThread.cpp b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
index 41fe1666b95bc4b781c78baddca1784ce08179f0..d4211b68570e79c4107dbd0788b5ecf48ce9a955 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -121,28 +121,26 @@ public:
void willProcessTask() override
{
// No tasks should get executed after we have closed.
- DCHECK(!m_workerThread->globalScope() || !m_workerThread->globalScope()->isClosing());
+ DCHECK(!m_workerThread->globalScope()->isClosing());
+
+ if (m_workerThread->isForciblyTerminated()) {
+ // The script has been terminated forcibly, which means we need to
+ // ask objects in the thread to stop working as soon as possible.
+ m_workerThread->prepareForShutdownOnWorkerThread();
+ }
}
void didProcessTask() override
{
Microtask::performCheckpoint(m_workerThread->isolate());
- if (WorkerOrWorkletGlobalScope* global = m_workerThread->globalScope()) {
- WorkerOrWorkletScriptController* scriptController = global->scriptController();
- if (scriptController)
- scriptController->getRejectedPromises()->processQueue();
- if (global->isClosing()) {
- // |m_workerThread| will eventually be requested to terminate.
- m_workerThread->workerReportingProxy().didCloseWorkerGlobalScope();
-
- // Stop further worker tasks to run after this point.
- m_workerThread->prepareForShutdownOnWorkerThread();
- } else if (m_workerThread->isForciblyTerminated()) {
- // The script has been terminated forcibly, which means we need
- // to ask objects in the thread to stop working as soon as
- // possible.
- m_workerThread->prepareForShutdownOnWorkerThread();
- }
+ WorkerOrWorkletGlobalScope* globalScope = m_workerThread->globalScope();
+ globalScope->scriptController()->getRejectedPromises()->processQueue();
+ if (globalScope->isClosing()) {
+ // |m_workerThread| will eventually be requested to terminate.
+ m_workerThread->workerReportingProxy().didCloseWorkerGlobalScope();
+
+ // Stop further worker tasks to run after this point.
+ m_workerThread->prepareForShutdownOnWorkerThread();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698