Commit c60a0590 authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Avoid leaking a shared worker global scope on a failed script load.

The spec tells us,

 http://whatwg.org/specs/web-apps/current-work/#run-a-worker

that in case of failure to load the script of a (shared) worker, we
should report the failure and abort (step 4.) The global scope's
closing flag will be left as false, meaning that we can safely shut
down and destroy the shared worker global scope. Do so.

R=
BUG=364390

Review URL: https://codereview.chromium.org/361443002

git-svn-id: svn://svn.chromium.org/blink/trunk@177178 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8f69e47b
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment