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

Unified Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp

Issue 2284303002: (WIP) ServiceWorker: Remove unnecessary WorkerThread::terminateAndWait() call
Patch Set: Created 4 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: 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()
« 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