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

Unified Diff: content/browser/browser_process_sub_thread.cc

Issue 9221008: Move cleanup that happens on IO thread destruction to content, so that not every embedder has to ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
Index: content/browser/browser_process_sub_thread.cc
===================================================================
--- content/browser/browser_process_sub_thread.cc (revision 117868)
+++ content/browser/browser_process_sub_thread.cc (working copy)
@@ -4,13 +4,18 @@
#include "content/browser/browser_process_sub_thread.h"
-#include "build/build_config.h"
-#include "content/browser/notification_service_impl.h"
-
#if defined(OS_WIN)
#include <Objbase.h>
#endif
+#include "base/debug/leak_tracker.h"
+#include "build/build_config.h"
+#include "content/browser/browser_child_process_host.h"
+#include "content/browser/in_process_webkit/indexed_db_key_utility_client.h"
+#include "content/browser/notification_service_impl.h"
+#include "content/public/common/url_fetcher.h"
+#include "net/url_request/url_request.h"
+
namespace content {
BrowserProcessSubThread::BrowserProcessSubThread(BrowserThread::ID identifier)
@@ -34,8 +39,14 @@
}
void BrowserProcessSubThread::CleanUp() {
+ if (BrowserThread::CurrentlyOn(BrowserThread::IO))
+ IOThreadPreCleanUp();
+
BrowserThreadImpl::CleanUp();
+ if (BrowserThread::CurrentlyOn(BrowserThread::IO))
+ IOThreadPostCleanUp();
+
delete notification_service_;
notification_service_ = NULL;
@@ -46,4 +57,24 @@
#endif
}
+void BrowserProcessSubThread::IOThreadPreCleanUp() {
+ // Kill all things that might be holding onto
+ // net::URLRequest/net::URLRequestContexts.
+
+ // Destroy all URLRequests started by URLFetchers.
+ content::URLFetcher::CancelAll();
+
+ IndexedDBKeyUtilityClient::Shutdown();
+
+ // If any child processes are still running, terminate them and
+ // and delete the BrowserChildProcessHost instances to release whatever
+ // IO thread only resources they are referencing.
+ BrowserChildProcessHost::TerminateAll();
+}
+
+void BrowserProcessSubThread::IOThreadPostCleanUp() {
+ // net::URLRequest instances must NOT outlive the IO thread.
+ base::debug::LeakTracker<net::URLRequest>::CheckForLeaks();
+}
+
} // namespace content
« no previous file with comments | « content/browser/browser_process_sub_thread.h ('k') | content/browser/in_process_webkit/indexed_db_key_utility_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698