diff options
Diffstat (limited to 'chrome/common/child_process_host.cc')
-rw-r--r-- | chrome/common/child_process_host.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc index 4269678..6618554 100644 --- a/chrome/common/child_process_host.cc +++ b/chrome/common/child_process_host.cc @@ -17,7 +17,12 @@ #include "chrome/common/process_watcher.h" #include "chrome/common/result_codes.h" -typedef std::list<ChildProcessInfo*> ChildProcessList; +#if defined(OS_WIN) +#include "chrome/common/plugin_messages.h" +#endif + +namespace { +typedef std::list<ChildProcessHost*> ChildProcessList; // The NotificationTask is used to notify about plugin process connection/ // disconnection. It is needed because the notifications in the @@ -39,6 +44,9 @@ class ChildNotificationTask : public Task { ChildProcessInfo info_; }; +} // namespace + + ChildProcessHost::ChildProcessHost( ProcessType type, ResourceDispatcherHost* resource_dispatcher_host) @@ -143,10 +151,22 @@ void ChildProcessHost::ListenerHook::OnMessageReceived( bool msg_is_ok = true; bool handled = host_->resource_dispatcher_host_->OnMessageReceived( msg, host_, &msg_is_ok); - if (!handled) - host_->OnMessageReceived(msg); - if (!msg_is_ok) + if (!handled) { +#if defined(OS_WIN) + if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { + // Must remove the process from the list now, in case it gets used for a + // new instance before our watcher tells us that the process terminated. + Singleton<ChildProcessList>::get()->remove(host_); + if (host_->CanShutdown()) + host_->Send(new PluginProcessMsg_Shutdown()); +#endif + } else { + host_->OnMessageReceived(msg); + } + } + + if (!msg_is_ok) base::KillProcess(host_->handle(), ResultCodes::KILLED_BAD_MESSAGE, false); #ifdef IPC_MESSAGE_LOG_ENABLED @@ -158,6 +178,7 @@ void ChildProcessHost::ListenerHook::OnMessageReceived( void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { host_->opening_channel_ = false; host_->OnChannelConnected(peer_pid); + host_->Send(new PluginProcessMsg_AskBeforeShutdown()); // Notify in the main loop of the connection. host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); @@ -186,7 +207,7 @@ ChildProcessHost::Iterator::Iterator(ProcessType type) ++(*this); } -ChildProcessInfo* ChildProcessHost::Iterator::operator++() { +ChildProcessHost* ChildProcessHost::Iterator::operator++() { do { ++iterator_; if (Done()) |