Chromium Code Reviews| 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 |