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

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

Issue 2324693003: Worker: Check forcible termination by WorkerThread::isForciblyTerminated() (Closed)
Patch Set: remove unnecessary header inclusion 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
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 55c0953a1132e38e8b28dda8e9ffa96c6f06e5a5..41fe1666b95bc4b781c78baddca1784ce08179f0 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThread.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThread.cpp
@@ -104,8 +104,7 @@ private:
return;
}
- m_workerThread->forciblyTerminateExecution();
- m_workerThread->setExitCode(lock, ExitCode::AsyncForciblyTerminated);
+ m_workerThread->forciblyTerminateExecution(lock, ExitCode::AsyncForciblyTerminated);
}
WorkerThread* m_workerThread;
@@ -138,7 +137,7 @@ public:
// Stop further worker tasks to run after this point.
m_workerThread->prepareForShutdownOnWorkerThread();
- } else if (scriptController && scriptController->isExecutionTerminating()) {
+ } 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.
@@ -397,9 +396,7 @@ void WorkerThread::terminateInternal(TerminationMode mode)
// main thread and the scheduled termination task never runs.
if (mode == TerminationMode::Forcible && m_exitCode == ExitCode::NotTerminated) {
DCHECK(m_scheduledForceTerminationTask);
- m_scheduledForceTerminationTask.reset();
- forciblyTerminateExecution();
- setExitCode(lock, ExitCode::SyncForciblyTerminated);
+ forciblyTerminateExecution(lock, ExitCode::SyncForciblyTerminated);
}
return;
}
@@ -413,8 +410,7 @@ void WorkerThread::terminateInternal(TerminationMode mode)
} else if (shouldScheduleToTerminateExecution(lock)) {
switch (mode) {
case TerminationMode::Forcible:
- forciblyTerminateExecution();
- setExitCode(lock, ExitCode::SyncForciblyTerminated);
+ forciblyTerminateExecution(lock, ExitCode::SyncForciblyTerminated);
break;
case TerminationMode::Graceful:
DCHECK(!m_scheduledForceTerminationTask);
@@ -458,12 +454,16 @@ bool WorkerThread::shouldScheduleToTerminateExecution(const MutexLocker& lock)
return false;
}
-void WorkerThread::forciblyTerminateExecution()
+void WorkerThread::forciblyTerminateExecution(const MutexLocker& lock, ExitCode exitCode)
{
DCHECK(isMainThread());
- DCHECK(m_globalScope);
- m_globalScope->scriptController()->willScheduleExecutionTermination();
+ DCHECK(isThreadStateMutexLocked(lock));
+
+ DCHECK(exitCode == ExitCode::SyncForciblyTerminated || exitCode == ExitCode::AsyncForciblyTerminated);
+ setExitCode(lock, exitCode);
+
isolate()->TerminateExecution();
+ m_scheduledForceTerminationTask.reset();
}
bool WorkerThread::isInShutdown()
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.h ('k') | third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698