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

Unified Diff: Source/web/WebSharedWorkerImpl.cpp

Issue 451603002: Fix leaks when the shared worker is requested to be terminated while loading the main script. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated sof's comment Created 6 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 | « LayoutTests/LeakExpectations ('k') | 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 26bf424af4d35d9f31903a5aadbac66b2d246068..4b5cdf6086872ccb64fbe05fcc25191471a1bce8 100644
--- a/Source/web/WebSharedWorkerImpl.cpp
+++ b/Source/web/WebSharedWorkerImpl.cpp
@@ -182,6 +182,10 @@ void WebSharedWorkerImpl::stopWorkerThread()
if (m_mainScriptLoader) {
m_mainScriptLoader->cancel();
m_mainScriptLoader.clear();
+ if (client())
+ client()->workerScriptLoadFailed();
+ delete this;
+ return;
}
if (m_workerThread)
m_workerThread->stop();
@@ -347,17 +351,16 @@ void WebSharedWorkerImpl::onScriptLoaderFinished()
{
ASSERT(m_loadingDocument);
ASSERT(m_mainScriptLoader);
- if (m_mainScriptLoader->failed() || m_askedToTerminate) {
+ if (m_askedToTerminate)
+ return;
+ if (m_mainScriptLoader->failed()) {
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;
+ // shut it down right here.
+ delete this;
return;
}
WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerGlobalScopeOnStart : DontPauseWorkerGlobalScopeOnStart;
« no previous file with comments | « LayoutTests/LeakExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698