diff options
Diffstat (limited to 'chrome/common/child_thread.cc')
-rw-r--r-- | chrome/common/child_thread.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc index 237e53c..22c82c0 100644 --- a/chrome/common/child_thread.cc +++ b/chrome/common/child_thread.cc @@ -11,13 +11,18 @@ #include "chrome/common/ipc_logging.h" #include "webkit/glue/webkit_glue.h" +#if defined(OS_WIN) +#include "chrome/common/plugin_messages.h" +#endif + // V8 needs a 1MB stack size. const size_t ChildThread::kV8StackSize = 1024 * 1024; ChildThread::ChildThread(Thread::Options options) : Thread("Chrome_ChildThread"), owner_loop_(MessageLoop::current()), - options_(options) { + options_(options), + check_with_browser_before_shutdown_(false) { DCHECK(owner_loop_); channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValue( switches::kProcessChannelID); @@ -66,6 +71,18 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) { if (resource_dispatcher_->OnMessageReceived(msg)) return; +#if defined(OS_WIN) + if (msg.type() == PluginProcessMsg_AskBeforeShutdown::ID) { + check_with_browser_before_shutdown_ = true; + return; + } + + if (msg.type() == PluginProcessMsg_Shutdown::ID) { + owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); + return; + } +#endif + if (msg.routing_id() == MSG_ROUTING_CONTROL) { OnControlMessageReceived(msg); } else { @@ -97,3 +114,16 @@ void ChildThread::CleanUp() { channel_.reset(); resource_dispatcher_.reset(); } + +void ChildThread::OnProcessFinalRelease() { + if (!check_with_browser_before_shutdown_) { + owner_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask()); + return; + } + + // The child process shutdown sequence is a request response based mechanism, + // where we send out an initial feeler request to the child process host + // instance in the browser to verify if it's ok to shutdown the child process. + // The browser then sends back a response if it's ok to shutdown. + Send(new PluginProcessHostMsg_ShutdownRequest); +} |