| Index: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
|
| index daedd57d2ea097b390f9602cf1368b45244b5291..ef787ab9689edbba4018d1f9d9f714cd4acd55a0 100644
|
| --- a/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp
|
| @@ -73,6 +73,7 @@
|
| #include "web/WorkerContentSettingsClient.h"
|
| #include "wtf/Functional.h"
|
| #include "wtf/PtrUtil.h"
|
| +#include "wtf/WTF.h"
|
| #include <memory>
|
|
|
| namespace blink {
|
| @@ -99,16 +100,16 @@ WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl(std::unique_ptr<WebServiceWorkerCon
|
| , m_pauseAfterDownloadState(DontPauseAfterDownload)
|
| , m_waitingForDebuggerState(NotWaitingForDebugger)
|
| {
|
| + DCHECK(isMainThread());
|
| runningWorkerInstances().add(this);
|
| }
|
|
|
| WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl()
|
| {
|
| - // Prevent onScriptLoaderFinished from deleting 'this'.
|
| - m_askedToTerminate = true;
|
| + DCHECK(isMainThread());
|
|
|
| - if (m_workerThread)
|
| - m_workerThread->terminateAndWait();
|
| + // Worker thread termination must be done before this point.
|
| + DCHECK(m_askedToTerminate);
|
|
|
| DCHECK(runningWorkerInstances().contains(this));
|
| runningWorkerInstances().remove(this);
|
| @@ -161,28 +162,22 @@ void WebEmbeddedWorkerImpl::terminateWorkerContext()
|
| if (m_askedToTerminate)
|
| return;
|
| m_askedToTerminate = true;
|
| - if (m_loadingShadowPage) {
|
| - // This deletes 'this'.
|
| - m_workerContextClient->workerContextFailedToStart();
|
| +
|
| + if (m_workerThread) {
|
| + m_workerThread->terminate();
|
| + m_workerInspectorProxy->workerThreadTerminated();
|
| + // WebServiceWorkerContextClient::workerContextDestroyed() that deletes
|
| + // 'this' will be called after worker thread termination is done.
|
| return;
|
| }
|
| +
|
| if (m_mainScriptLoader) {
|
| m_mainScriptLoader->cancel();
|
| m_mainScriptLoader.clear();
|
| - // This deletes 'this'.
|
| - m_workerContextClient->workerContextFailedToStart();
|
| - return;
|
| - }
|
| - if (!m_workerThread) {
|
| - // The worker thread has not been created yet if the worker is asked to
|
| - // terminate during waiting for debugger or paused after download.
|
| - DCHECK(m_workerStartData.waitForDebuggerMode == WebEmbeddedWorkerStartData::WaitForDebugger || m_pauseAfterDownloadState == IsPausedAfterDownload);
|
| - // This deletes 'this'.
|
| - m_workerContextClient->workerContextFailedToStart();
|
| - return;
|
| }
|
| - m_workerThread->terminate();
|
| - m_workerInspectorProxy->workerThreadTerminated();
|
| +
|
| + // This deletes 'this'.
|
| + m_workerContextClient->workerContextFailedToStart();
|
| }
|
|
|
| void WebEmbeddedWorkerImpl::resumeAfterDownload()
|
|
|