diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 19:26:58 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-17 19:26:58 +0000 |
commit | af6699372a232fce9d6f8484d64d128150392f66 (patch) | |
tree | 159fb9e8f4c9449da9e8293f52fbd00f2a2b8019 | |
parent | b52a3f33699d38c121e59b4f01338e4c8e592f02 (diff) | |
download | chromium_src-af6699372a232fce9d6f8484d64d128150392f66.zip chromium_src-af6699372a232fce9d6f8484d64d128150392f66.tar.gz chromium_src-af6699372a232fce9d6f8484d64d128150392f66.tar.bz2 |
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
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 9 | ||||
-rw-r--r-- | chrome/browser/io_thread.cc | 22 | ||||
-rw-r--r-- | content/browser/browser_process_sub_thread.cc | 37 | ||||
-rw-r--r-- | content/browser/browser_process_sub_thread.h | 5 | ||||
-rw-r--r-- | content/browser/in_process_webkit/indexed_db_key_utility_client.h | 2 |
5 files changed, 42 insertions, 33 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index cf139193..2f45144 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -77,7 +77,6 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/plugin_service.h" #include "content/public/browser/render_process_host.h" -#include "content/public/common/url_fetcher.h" #include "media/audio/audio_manager.h" #include "net/socket/client_socket_pool_manager.h" #include "net/url_request/url_request_context_getter.h" @@ -198,14 +197,6 @@ void BrowserProcessImpl::StartTearDown() { // those things during teardown. notification_ui_manager_.reset(); - // FIXME - We shouldn't need this, it's because of DefaultRequestContext! :( - // We need to kill off all URLFetchers using profile related - // URLRequestContexts. Normally that'd be covered by deleting the Profiles, - // but we have some URLFetchers using the DefaultRequestContext, so they need - // to be cancelled too. Remove this when DefaultRequestContext goes away. - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&content::URLFetcher::CancelAll)); - // Need to clear profiles (download managers) before the io_thread_. profile_manager_.reset(); diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index d1b9f30..6ad01f6 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -32,8 +32,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" -#include "content/browser/gpu/gpu_process_host.h" -#include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_client.h" #include "content/public/common/url_fetcher.h" @@ -478,27 +476,14 @@ void IOThread::CleanUp() { delete sdch_manager_; sdch_manager_ = NULL; - // Step 1: Kill all things that might be holding onto - // net::URLRequest/net::URLRequestContexts. - #if defined(USE_NSS) net::ShutdownOCSP(); #endif // defined(USE_NSS) - // 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(); - system_url_request_context_getter_ = NULL; - // Step 2: Release objects that the net::URLRequestContext could have been - // pointing to. + // Release objects that the net::URLRequestContext could have been pointing + // to. // This must be reset before the ChromeNetLog is destroyed. network_change_observer_.reset(); @@ -508,9 +493,6 @@ void IOThread::CleanUp() { delete globals_; globals_ = NULL; - // net::URLRequest instances must NOT outlive the IO thread. - base::debug::LeakTracker<net::URLRequest>::CheckForLeaks(); - base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); } 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 <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::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<net::URLRequest>::CheckForLeaks(); +} + } // namespace content diff --git a/content/browser/browser_process_sub_thread.h b/content/browser/browser_process_sub_thread.h index a41bfdd..18a3b0b 100644 --- a/content/browser/browser_process_sub_thread.h +++ b/content/browser/browser_process_sub_thread.h @@ -35,6 +35,11 @@ class CONTENT_EXPORT BrowserProcessSubThread : public BrowserThreadImpl { virtual void CleanUp() OVERRIDE; private: + // These methods encapsulate cleanup that needs to happen on the IO thread + // before/after we call the embedder's CleanUp function. + void IOThreadPreCleanUp(); + void IOThreadPostCleanUp(); + // Each specialized thread has its own notification service. // Note: We don't use scoped_ptr because the destructor runs on the wrong // thread. diff --git a/content/browser/in_process_webkit/indexed_db_key_utility_client.h b/content/browser/in_process_webkit/indexed_db_key_utility_client.h index ca97235..ad927e4 100644 --- a/content/browser/in_process_webkit/indexed_db_key_utility_client.h +++ b/content/browser/in_process_webkit/indexed_db_key_utility_client.h @@ -43,7 +43,7 @@ class IndexedDBKeyUtilityClient { const string16& key_path); // Shut down the underlying implementation. Must be called on the IO thread. - CONTENT_EXPORT static void Shutdown(); + static void Shutdown(); private: friend struct base::DefaultLazyInstanceTraits<IndexedDBKeyUtilityClient>; |