Index: Source/core/workers/WorkerThread.cpp |
diff --git a/Source/core/workers/WorkerThread.cpp b/Source/core/workers/WorkerThread.cpp |
index ff101dd1e8a5f4749ca24b0bb1e505e6c8bed7e5..ffad47c16ccce2a13264d94a44c06dec7c6a17c3 100644 |
--- a/Source/core/workers/WorkerThread.cpp |
+++ b/Source/core/workers/WorkerThread.cpp |
@@ -314,8 +314,8 @@ void WorkerThread::initialize(PassOwnPtr<WorkerThreadStartupData> startupData) |
} |
m_microtaskRunner = adoptPtr(new WorkerMicrotaskRunner(this)); |
+ initializeBackingThread(); |
backingThread().addTaskObserver(m_microtaskRunner.get()); |
- backingThread().initialize(); |
m_isolate = initializeIsolate(); |
m_workerGlobalScope = createWorkerGlobalScope(startupData); |
@@ -373,7 +373,7 @@ void WorkerThread::shutdown() |
m_workerGlobalScope = nullptr; |
backingThread().removeTaskObserver(m_microtaskRunner.get()); |
- backingThread().shutdown(); |
+ shutdownBackingThread(); |
destroyIsolate(); |
kinuko
2015/06/03 05:05:03
I feel we should do m_isolate = nullptr here (rath
sadrul
2015/06/03 14:31:38
Good point. Done.
|
m_microtaskRunner = nullptr; |
@@ -438,6 +438,7 @@ void WorkerThread::stopInternal() |
} |
// Ensure that tasks are being handled by thread event loop. If script execution weren't forbidden, a while(1) loop in JS could keep the thread alive forever. |
+ m_workerGlobalScope->script()->willScheduleExecutionTermination(); |
terminateV8Execution(); |
InspectorInstrumentation::didKillAllExecutionContextTasks(m_workerGlobalScope.get()); |
@@ -507,6 +508,18 @@ void WorkerThread::postDelayedTask(const WebTraceLocation& location, PassOwnPtr< |
backingThread().postDelayedTask(location, WorkerThreadTask::create(*this, task, true).leakPtr(), delayMs); |
} |
+void WorkerThread::initializeBackingThread() |
+{ |
+ ASSERT(isCurrentThread()); |
+ backingThread().initialize(); |
+} |
+ |
+void WorkerThread::shutdownBackingThread() |
+{ |
+ ASSERT(isCurrentThread()); |
+ backingThread().shutdown(); |
+} |
+ |
v8::Isolate* WorkerThread::initializeIsolate() |
{ |
ASSERT(isCurrentThread()); |
@@ -539,7 +552,6 @@ void WorkerThread::destroyIsolate() |
void WorkerThread::terminateV8Execution() |
{ |
ASSERT(isMainThread()); |
- m_workerGlobalScope->script()->willScheduleExecutionTermination(); |
v8::V8::TerminateExecution(m_isolate); |
} |