summaryrefslogtreecommitdiffstats
path: root/chrome/common/child_thread.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_thread.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_thread.cc')
-rw-r--r--chrome/common/child_thread.cc32
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);
+}