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

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

Issue 462423003: WorkerThread should not start execution if WorkerThread::stop is already called (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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: Source/core/workers/WorkerThread.cpp
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp
index 6c163b391b07dcb30bc14cd5ca9b497d6ade0d47..7205e54255b53fed4bf2b1fa0e88a1b50d25f090 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -240,12 +240,20 @@ void WorkerThread::initialize()
KURL scriptURL = m_startupData->m_scriptURL;
String sourceCode = m_startupData->m_sourceCode;
WorkerThreadStartMode startMode = m_startupData->m_startMode;
- m_microtaskRunner = adoptPtr(new MicrotaskRunner);
- m_thread->addTaskObserver(m_microtaskRunner.get());
{
MutexLocker lock(m_threadCreationMutex);
+ // The worker was terminated before the thread had a chance to run.
+ if (m_terminated) {
+ // Notify the proxy that the WorkerGlobalScope has been disposed of.
+ // This can free this thread object, hence it must not be touched afterwards.
+ m_workerReportingProxy.workerGlobalScopeDestroyed();
haraken 2014/08/13 04:48:54 I think that the name "workerGlobalScopeDestroyed"
+ return;
+ }
+
+ m_microtaskRunner = adoptPtr(new MicrotaskRunner);
+ m_thread->addTaskObserver(m_microtaskRunner.get());
m_pendingGCRunner = adoptPtr(new PendingGCRunner);
m_messageLoopInterruptor = adoptPtr(new MessageLoopInterruptor(m_thread.get()));
m_thread->addTaskObserver(m_pendingGCRunner.get());
@@ -255,12 +263,6 @@ void WorkerThread::initialize()
m_sharedTimer = adoptPtr(new WorkerSharedTimer(this));
PlatformThreadData::current().threadTimers().setSharedTimer(m_sharedTimer.get());
-
- if (m_terminated) {
- // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet,
- // forbidExecution() couldn't be called from stop().
- m_workerGlobalScope->script()->forbidExecution();
- }
}
// The corresponding call to didStopWorkerRunLoop is in
@@ -378,6 +380,7 @@ void WorkerThread::stop()
// If stop has already been called, just return.
if (m_terminated)
return;
+ m_terminated = true;
// Signal the thread to notify that the thread's stopping.
if (m_shutdownEvent)
@@ -392,7 +395,6 @@ void WorkerThread::stop()
InspectorInstrumentation::didKillAllExecutionContextTasks(m_workerGlobalScope.get());
m_debuggerMessageQueue.kill();
postTask(WorkerThreadShutdownStartTask::create());
- m_terminated = true;
}
bool WorkerThread::isCurrentThread() const
« 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