From af6699372a232fce9d6f8484d64d128150392f66 Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Tue, 17 Jan 2012 19:26:58 +0000 Subject: Move cleanup that happens on IO thread destruction to content, so that not every embedder has to know to do it. This also allows us to hide some of these functions from embedders. BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9221008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117934 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/browser_process_sub_thread.cc | 37 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'content/browser/browser_process_sub_thread.cc') diff --git a/content/browser/browser_process_sub_thread.cc b/content/browser/browser_process_sub_thread.cc index 08fd712..35566f0 100644 --- a/content/browser/browser_process_sub_thread.cc +++ b/content/browser/browser_process_sub_thread.cc @@ -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 #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::Init() { } 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 @@ void BrowserProcessSubThread::CleanUp() { #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::CheckForLeaks(); +} + } // namespace content -- cgit v1.1