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

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..b32b9e7d8ac4f80e2ce898576fe178b2ca75aa4c 100644
--- a/Source/core/workers/WorkerThread.cpp
+++ b/Source/core/workers/WorkerThread.cpp
@@ -240,12 +240,15 @@ 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());
horo 2014/08/13 03:32:29 Why do you remove these lines?
haraken 2014/08/13 04:13:42 These lines are moved to after the 'if(m_terminate
{
MutexLocker lock(m_threadCreationMutex);
+ if (m_terminated) // The worker was terminated before the thread had a chance to run.
+ 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 +258,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 +375,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 +390,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