summaryrefslogtreecommitdiffstats
path: root/chrome/common/child_process_host.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 20:45:59 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-27 20:45:59 +0000
commit51d70e07bd5d991420bc0f14ff05f1a9b72d02db (patch)
tree718c0b24680c1b14eb4570403cc15b8d09b4002d /chrome/common/child_process_host.cc
parent70ac249f04337f0040ad63a72ced111d87fdc73a (diff)
downloadchromium_src-51d70e07bd5d991420bc0f14ff05f1a9b72d02db.zip
chromium_src-51d70e07bd5d991420bc0f14ff05f1a9b72d02db.tar.gz
chromium_src-51d70e07bd5d991420bc0f14ff05f1a9b72d02db.tar.bz2
Refactor plugin process code which checks with the browser process before shutdown, to avoid races in which the browser process thinks the process is fine to use while it's shutting down. I also removed PluginProcess/WorkerProcess since they didn't have any code in them now.
I removed the plugin process code which waits 10 seconds before shutting itself down. That was a premature optimization, since testing with/without this didn't show any difference (see http://www/~jabdelmalek/chrome/test/plugins/processes.html). In both cases, the plugin on a page would get recreated in less than 100ms, even with reusing or starting a plugin process from scratch. We already spawn new renderer processes on back and forth if it's a different origin, and the plugin will be in the cache anyways. Review URL: http://codereview.chromium.org/53091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_process_host.cc')
-rw-r--r--chrome/common/child_process_host.cc31
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())