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

Side by Side Diff: Source/web/WebSharedWorkerImpl.cpp

Issue 424653002: Fix SharedWorker leak when script load has failed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: hasPendingActivity 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 m_webView->close(); 172 m_webView->close();
173 m_mainFrame->close(); 173 m_mainFrame->close();
174 } 174 }
175 175
176 void WebSharedWorkerImpl::stopWorkerThread() 176 void WebSharedWorkerImpl::stopWorkerThread()
177 { 177 {
178 if (m_askedToTerminate) 178 if (m_askedToTerminate)
179 return; 179 return;
180 m_askedToTerminate = true; 180 m_askedToTerminate = true;
181
182 bool hasPendingActivity = false;
181 if (m_mainScriptLoader) { 183 if (m_mainScriptLoader) {
182 m_mainScriptLoader->cancel(); 184 m_mainScriptLoader->cancel();
183 m_mainScriptLoader.clear(); 185 m_mainScriptLoader.clear();
186 hasPendingActivity = true;
184 } 187 }
185 if (m_workerThread) 188 if (m_workerThread) {
186 m_workerThread->stop(); 189 m_workerThread->stop();
190 hasPendingActivity = true;
191 }
192
193 if (!hasPendingActivity) {
194 // If there are no active WorkerThread, |workerGlobalScopeClosed()|
195 // callback to delete this is never called, so we should clean up here.
196 delete this;
197 }
187 } 198 }
188 199
189 void WebSharedWorkerImpl::initializeLoader(const WebURL& url) 200 void WebSharedWorkerImpl::initializeLoader(const WebURL& url)
190 { 201 {
191 // Create 'shadow page'. This page is never displayed, it is used to proxy t he 202 // Create 'shadow page'. This page is never displayed, it is used to proxy t he
192 // loading requests from the worker context to the rest of WebKit and Chromi um 203 // loading requests from the worker context to the rest of WebKit and Chromi um
193 // infrastructure. 204 // infrastructure.
194 ASSERT(!m_webView); 205 ASSERT(!m_webView);
195 m_webView = WebView::create(0); 206 m_webView = WebView::create(0);
196 m_webView->settings()->setOfflineWebApplicationCacheEnabled(RuntimeEnabledFe atures::applicationCacheEnabled()); 207 m_webView->settings()->setOfflineWebApplicationCacheEnabled(RuntimeEnabledFe atures::applicationCacheEnabled());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 workerThread()->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa ckendTask, String(message))); 459 workerThread()->postDebuggerTask(createCrossThreadTask(dispatchOnInspectorBa ckendTask, String(message)));
449 workerThread()->interruptAndDispatchInspectorCommands(); 460 workerThread()->interruptAndDispatchInspectorCommands();
450 } 461 }
451 462
452 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) 463 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
453 { 464 {
454 return new WebSharedWorkerImpl(client); 465 return new WebSharedWorkerImpl(client);
455 } 466 }
456 467
457 } // namespace blink 468 } // namespace blink
OLDNEW
« 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