diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 23:05:27 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 23:05:27 +0000 |
commit | 325a71ffd6569bc84cd2d0f2586dac2f3e9fe95a (patch) | |
tree | 09f310135f18917f2c2aafcdc19b5a6570d82205 /chrome/browser | |
parent | 0abc3c589cfcffd655867ef4ceb9db3c225da064 (diff) | |
download | chromium_src-325a71ffd6569bc84cd2d0f2586dac2f3e9fe95a.zip chromium_src-325a71ffd6569bc84cd2d0f2586dac2f3e9fe95a.tar.gz chromium_src-325a71ffd6569bc84cd2d0f2586dac2f3e9fe95a.tar.bz2 |
Kill all child processes at IO thread shutdown time.
BUG=none
TEST=wrapper-map-gc.html leaks a WorkerProcessHost which this cleanup logic takes care of
Review URL: http://codereview.chromium.org/2063015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/child_process_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/child_process_host.h | 3 | ||||
-rw-r--r-- | chrome/browser/io_thread.cc | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/chrome/browser/child_process_host.cc b/chrome/browser/child_process_host.cc index 0c87021..773f927 100644 --- a/chrome/browser/child_process_host.cc +++ b/chrome/browser/child_process_host.cc @@ -12,6 +12,7 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/singleton.h" +#include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/waitable_event.h" #include "chrome/browser/chrome_thread.h" @@ -130,6 +131,13 @@ void ChildProcessHost::SetCrashReporterCommandLine(CommandLine* command_line) { #endif // OS_MACOSX } +// static +void ChildProcessHost::TerminateAll() { + // Make a copy since the ChildProcessHost dtor mutates the original list. + ChildProcessList copy = *(Singleton<ChildProcessList>::get()); + STLDeleteElements(©); +} + void ChildProcessHost::Launch( #if defined(OS_WIN) const FilePath& exposed_dir, diff --git a/chrome/browser/child_process_host.h b/chrome/browser/child_process_host.h index e735940..b4f661b 100644 --- a/chrome/browser/child_process_host.h +++ b/chrome/browser/child_process_host.h @@ -54,6 +54,9 @@ class ChildProcessHost : public ResourceDispatcherHost::Receiver, // currently-executing process. This function is a no-op on Windows. static void SetCrashReporterCommandLine(CommandLine* command_line); + // Terminates all child processes and deletes each ChildProcessHost instance. + static void TerminateAll(); + // ResourceDispatcherHost::Receiver implementation: virtual bool Send(IPC::Message* msg); diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index ca5151b..0382ec4d 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -146,6 +146,11 @@ void IOThread::Init() { } void IOThread::CleanUp() { + // If any child processes are still running, terminate them and + // and delete the ChildProcessHost instances to release whatever + // IO thread only resources they are referencing. + ChildProcessHost::TerminateAll(); + // Not initialized in Init(). May not be initialized. if (dns_master_) { DCHECK(prefetch_observer_); |