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

Unified Diff: Source/web/WebSharedWorkerImpl.cpp

Issue 361443002: Avoid leaking a shared worker global scope on a failed script load. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid deleting a terminating WebSharedWorkerImpl Created 6 years, 6 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: Source/web/WebSharedWorkerImpl.cpp
diff --git a/Source/web/WebSharedWorkerImpl.cpp b/Source/web/WebSharedWorkerImpl.cpp
index ac6d7069f343c3175685570f64621c55804083a7..b36029b4be8659ac126feb7ecafe6085d614ab0c 100644
--- a/Source/web/WebSharedWorkerImpl.cpp
+++ b/Source/web/WebSharedWorkerImpl.cpp
@@ -177,8 +177,10 @@ void WebSharedWorkerImpl::stopWorkerThread()
if (m_askedToTerminate)
return;
m_askedToTerminate = true;
- if (m_mainScriptLoader)
+ if (m_mainScriptLoader) {
m_mainScriptLoader->cancel();
+ m_mainScriptLoader.clear();
+ }
if (m_workerThread)
m_workerThread->stop();
}
@@ -344,9 +346,16 @@ void WebSharedWorkerImpl::onScriptLoaderFinished()
ASSERT(m_loadingDocument);
ASSERT(m_mainScriptLoader);
if (m_mainScriptLoader->failed() || m_askedToTerminate) {
- m_mainScriptLoader.clear();
+ m_mainScriptLoader->cancel();
if (client())
client()->workerScriptLoadFailed();
+
+ // The SharedWorker was unable to load the initial script, so
+ // shut it down right here unless we're here handling a load
+ // cancellation failure triggered by an explicit shared worker
+ // termination call (via terminateWorkerContext().)
+ if (!m_askedToTerminate)
+ delete this;
return;
}
WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart;
« 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