Index: content/browser/child_process_launcher.cc |
=================================================================== |
--- content/browser/child_process_launcher.cc (revision 86295) |
+++ content/browser/child_process_launcher.cc (working copy) |
@@ -105,6 +105,7 @@ |
#endif |
CommandLine* cmd_line) { |
scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); |
+ process_type_ = cmd_line->GetSwitchValueASCII(switches::kProcessType); |
base::ProcessHandle handle = base::kNullProcessHandle; |
#if defined(OS_WIN) |
handle = sandbox::StartProcessWithAccess(cmd_line, exposed_dir); |
@@ -210,16 +211,30 @@ |
if (!process_.handle()) |
return; |
+ const int kPluginProcessTerminateTimeoutMs = 2000; |
+ |
// On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So |
// don't this on the UI/IO threads. |
- BrowserThread::PostTask( |
- BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
- NewRunnableFunction( |
- &ChildProcessLauncher::Context::TerminateInternal, |
-#if defined(OS_LINUX) |
- zygote_, |
-#endif |
- process_.handle())); |
+ // Allow plugins to shutdown gracefully before terminating the process. |
+ if (process_type_ == switches::kPluginProcess) { |
jam
2011/05/23 22:32:59
ChildProcessLauncher is the base class that's used
|
+ BrowserThread::PostDelayedTask( |
+ BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
+ NewRunnableFunction( |
+ &ChildProcessLauncher::Context::TerminateInternal, |
+ #if defined(OS_LINUX) |
+ zygote_, |
+ #endif |
+ process_.handle()), kPluginProcessTerminateTimeoutMs); |
+ } else { |
+ BrowserThread::PostTask( |
+ BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
+ NewRunnableFunction( |
+ &ChildProcessLauncher::Context::TerminateInternal, |
+ #if defined(OS_LINUX) |
+ zygote_, |
+ #endif |
+ process_.handle())); |
+ } |
process_.set_handle(base::kNullProcessHandle); |
} |
@@ -257,6 +272,7 @@ |
BrowserThread::ID client_thread_id_; |
base::Process process_; |
bool starting_; |
+ std::string process_type_; |
#if defined(OS_LINUX) |
bool zygote_; |