summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 19:26:58 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 19:26:58 +0000
commitaf6699372a232fce9d6f8484d64d128150392f66 (patch)
tree159fb9e8f4c9449da9e8293f52fbd00f2a2b8019 /content/browser
parentb52a3f33699d38c121e59b4f01338e4c8e592f02 (diff)
downloadchromium_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
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/browser_process_sub_thread.cc37
-rw-r--r--content/browser/browser_process_sub_thread.h5
-rw-r--r--content/browser/in_process_webkit/indexed_db_key_utility_client.h2
3 files changed, 40 insertions, 4 deletions
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>;