Commit 0e0f1297 authored by kouhei@chromium.org's avatar kouhei@chromium.org

Fix SharedWorker leak when script load has failed.

When SharedWorker script load has failed and the |WebSharedWorkerImpl|
was explicit told to terminate, the |WebSharedWorkerImpl| instance
was never deleted.

This CL fixes the issue by invoking "delete this" when a worker thread
instance does not exist in |stopWorkerThread()|.

TEST=fast/workers/worker-crash-with-invalid-location.html doesn't leak when --enable-leak-detection
BUG=364390

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

git-svn-id: svn://svn.chromium.org/blink/trunk@179011 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 640c6fa4
...@@ -178,12 +178,23 @@ void WebSharedWorkerImpl::stopWorkerThread() ...@@ -178,12 +178,23 @@ void WebSharedWorkerImpl::stopWorkerThread()
if (m_askedToTerminate) if (m_askedToTerminate)
return; return;
m_askedToTerminate = true; m_askedToTerminate = true;
bool hasPendingActivity = false;
if (m_mainScriptLoader) { if (m_mainScriptLoader) {
m_mainScriptLoader->cancel(); m_mainScriptLoader->cancel();
m_mainScriptLoader.clear(); m_mainScriptLoader.clear();
hasPendingActivity = true;
} }
if (m_workerThread) if (m_workerThread) {
m_workerThread->stop(); m_workerThread->stop();
hasPendingActivity = true;
}
if (!hasPendingActivity) {
// If there are no active WorkerThread, |workerGlobalScopeClosed()|
// callback to delete this is never called, so we should clean up here.
delete this;
}
} }
void WebSharedWorkerImpl::initializeLoader(const WebURL& url) void WebSharedWorkerImpl::initializeLoader(const WebURL& url)
......
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