| Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
|
| diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
|
| index de797adf0bd59754688ba70c3dbda8872bb9bee5..2458e8af75c6f2bf7796ad32a3655d418342a5f8 100644
|
| --- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
|
| +++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThread.cpp
|
| @@ -15,7 +15,6 @@
|
| #include "platform/WaitableEvent.h"
|
| #include "platform/WebThreadSupportingGC.h"
|
| #include "public/platform/Platform.h"
|
| -#include "wtf/Assertions.h"
|
|
|
| namespace blink {
|
|
|
| @@ -40,10 +39,20 @@
|
| s_instance = new BackingThreadHolder;
|
| }
|
|
|
| + static void terminateExecution()
|
| + {
|
| + MutexLocker locker(holderInstanceMutex());
|
| + if (s_instance && s_instance->m_initialized) {
|
| + s_instance->thread()->isolate()->TerminateExecution();
|
| + s_instance->m_terminatingExecution = true;
|
| + }
|
| + }
|
| +
|
| static void clear()
|
| {
|
| MutexLocker locker(holderInstanceMutex());
|
| if (s_instance) {
|
| + DCHECK(!s_instance->m_initialized || s_instance->m_terminatingExecution);
|
| s_instance->shutdownAndWait();
|
| delete s_instance;
|
| s_instance = nullptr;
|
| @@ -76,8 +85,8 @@
|
| void initializeOnThread()
|
| {
|
| MutexLocker locker(holderInstanceMutex());
|
| - DCHECK(!m_initialized);
|
| - m_thread->initialize();
|
| + DCHECK_EQ(0u, m_thread->workerScriptCount()) << "BackingThreadHolder should be the first to attach to WorkerBackingThread";
|
| + m_thread->attach();
|
| m_initialized = true;
|
| }
|
|
|
| @@ -91,11 +100,13 @@
|
|
|
| void shutdownOnThread(WaitableEvent* doneEvent)
|
| {
|
| - m_thread->shutdown();
|
| + DCHECK_EQ(1u, m_thread->workerScriptCount()) << "BackingThreadHolder should be the last to detach from WorkerBackingThread";
|
| + m_thread->detach();
|
| doneEvent->signal();
|
| }
|
|
|
| OwnPtr<WorkerBackingThread> m_thread;
|
| + bool m_terminatingExecution = false;
|
| bool m_initialized = false;
|
|
|
| static BackingThreadHolder* s_instance;
|
| @@ -140,6 +151,12 @@
|
| BackingThreadHolder::ensureInstance();
|
| }
|
|
|
| +void CompositorWorkerThread::terminateExecution()
|
| +{
|
| + DCHECK(isMainThread());
|
| + BackingThreadHolder::terminateExecution();
|
| +}
|
| +
|
| void CompositorWorkerThread::clearSharedBackingThread()
|
| {
|
| DCHECK(isMainThread());
|
|
|