summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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/browser
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/browser')
-rw-r--r--chrome/browser/browser_shutdown.cc6
-rw-r--r--chrome/browser/plugin_process_host.cc26
-rw-r--r--chrome/browser/plugin_process_host.h6
-rw-r--r--chrome/browser/plugin_service.cc27
-rw-r--r--chrome/browser/plugin_service.h27
-rw-r--r--chrome/browser/worker_host/worker_process_host.h2
6 files changed, 5 insertions, 89 deletions
diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc
index 40e470f..23aa42d 100644
--- a/chrome/browser/browser_shutdown.cc
+++ b/chrome/browser/browser_shutdown.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/first_run.h"
#include "chrome/browser/jankometer.h"
#include "chrome/browser/metrics/metrics_service.h"
-#include "chrome/browser/plugin_service.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
@@ -106,11 +105,6 @@ void Shutdown() {
// Notifies we are going away.
g_browser_process->shutdown_event()->Signal();
- PluginService* plugin_service = PluginService::GetInstance();
- if (plugin_service) {
- plugin_service->Shutdown();
- }
-
PrefService* prefs = g_browser_process->local_state();
chrome_browser_net::SaveHostNamesForNextStartup(prefs);
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index e7a7f30..5031a35 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -505,8 +505,6 @@ void PluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_DownloadUrl, OnDownloadUrl)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetPluginFinderUrl,
OnGetPluginFinderUrl)
- IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ShutdownRequest,
- OnPluginShutdownRequest)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginMessage, OnPluginMessage)
IPC_MESSAGE_HANDLER(PluginProcessHostMsg_GetCookies, OnGetCookies)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginProcessHostMsg_ResolveProxy,
@@ -657,21 +655,6 @@ void PluginProcessHost::OnGetPluginFinderUrl(std::string* plugin_finder_url) {
*plugin_finder_url = kDefaultPluginFinderURL;
}
-void PluginProcessHost::OnPluginShutdownRequest() {
-#if defined(OS_WIN)
- DCHECK(MessageLoop::current() ==
- ChromeThread::GetMessageLoop(ChromeThread::IO));
-
- // If we have pending channel open requests from the renderers, then
- // refuse the shutdown request from the plugin process.
- bool ok_to_shutdown = sent_requests_.empty();
- Send(new PluginProcessMsg_ShutdownResponse(ok_to_shutdown));
-#else
- // TODO(port): Port plugin_messages_internal.h.
- NOTIMPLEMENTED();
-#endif
-}
-
void PluginProcessHost::OnPluginMessage(
const std::vector<uint8>& data) {
DCHECK(MessageLoop::current() ==
@@ -684,12 +667,3 @@ void PluginProcessHost::OnPluginMessage(
chrome_plugin->functions().on_message(data_ptr, data_len);
}
}
-
-void PluginProcessHost::Shutdown() {
-#if defined(OS_WIN)
- Send(new PluginProcessMsg_BrowserShutdown);
-#else
- // TODO(port): Port plugin_messages_internal.h.
- NOTIMPLEMENTED();
-#endif
-}
diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h
index bc15ca2..71b7c77 100644
--- a/chrome/browser/plugin_process_host.h
+++ b/chrome/browser/plugin_process_host.h
@@ -75,9 +75,6 @@ class PluginProcessHost : public ChildProcessHost,
void OnModalDialogResponse(const std::string& json_retval,
IPC::Message* sync_result);
- // Shuts down the current plugin process instance.
- void Shutdown();
-
const WebPluginInfo& info() const { return info_; }
#if defined(OS_WIN)
@@ -106,7 +103,6 @@ class PluginProcessHost : public ChildProcessHost,
void OnGetCookies(uint32 request_context, const GURL& url,
std::string* cookies);
void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
- void OnPluginShutdownRequest();
void OnPluginMessage(const std::vector<uint8>& data);
#if defined(OS_WIN)
@@ -114,6 +110,8 @@ class PluginProcessHost : public ChildProcessHost,
void OnDestroyWindow(HWND window);
#endif
+ virtual bool CanShutdown() { return sent_requests_.empty(); }
+
struct ChannelRequest {
ChannelRequest(ResourceMessageFilter* renderer_message_filter,
const std::string& m, IPC::Message* r) :
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index 26f791b..d46a1d5 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -27,8 +27,7 @@ PluginService* PluginService::GetInstance() {
PluginService::PluginService()
: main_message_loop_(MessageLoop::current()),
resource_dispatcher_host_(NULL),
- ui_locale_(g_browser_process->GetApplicationLocale()),
- plugin_shutdown_handler_(new ShutdownHandler) {
+ ui_locale_(g_browser_process->GetApplicationLocale()) {
// Have the NPAPI plugin list search for Chrome plugins as well.
ChromePluginLib::RegisterPluginsWithNPAPI();
// Load the one specified on the command line as well.
@@ -172,27 +171,3 @@ bool PluginService::HavePluginFor(const std::string& mime_type,
allow_wildcard, &info,
NULL);
}
-
-void PluginService::Shutdown() {
- plugin_shutdown_handler_->InitiateShutdown();
-}
-
-void PluginService::OnShutdown() {
- for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
- !iter.Done(); ++iter) {
- static_cast<PluginProcessHost*>(*iter)->Shutdown();
- }
-}
-
-void PluginService::ShutdownHandler::InitiateShutdown() {
- g_browser_process->io_thread()->message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ShutdownHandler::OnShutdown));
-}
-
-void PluginService::ShutdownHandler::OnShutdown() {
- PluginService* plugin_service = PluginService::GetInstance();
- if (plugin_service) {
- plugin_service->OnShutdown();
- }
-}
diff --git a/chrome/browser/plugin_service.h b/chrome/browser/plugin_service.h
index d4f9368..d193cda 100644
--- a/chrome/browser/plugin_service.h
+++ b/chrome/browser/plugin_service.h
@@ -101,10 +101,6 @@ class PluginService {
return resource_dispatcher_host_;
}
- // Initiates shutdown on all running PluginProcessHost instances.
- // Can be invoked on the main thread.
- void Shutdown();
-
private:
friend struct DefaultSingletonTraits<PluginService>;
@@ -113,9 +109,6 @@ class PluginService {
PluginService();
~PluginService();
- // Shutdown handler which executes in the context of the IO thread.
- void OnShutdown();
-
// mapping between plugin path and PluginProcessHost
typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap;
PluginMap plugin_hosts_;
@@ -136,26 +129,6 @@ class PluginService {
// webkit_glue since this class is called on the main and IO thread.
Lock lock_;
- // Handles plugin process shutdown.
- class ShutdownHandler : public base::RefCountedThreadSafe<ShutdownHandler> {
- public:
- ShutdownHandler() {}
- ~ShutdownHandler() {}
-
- // Initiates plugin process shutdown. Ensures that the actual shutdown
- // happens on the io thread.
- void InitiateShutdown();
-
- private:
- // Shutdown handler which runs on the io thread.
- void OnShutdown();
-
- DISALLOW_COPY_AND_ASSIGN(ShutdownHandler);
- };
-
- friend class ShutdownHandler;
- scoped_refptr<ShutdownHandler> plugin_shutdown_handler_;
-
DISALLOW_COPY_AND_ASSIGN(PluginService);
};
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 0a885ea..cf8072c 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -44,6 +44,8 @@ class WorkerProcessHost : public ChildProcessHost {
// Called when a message arrives from the worker process.
void OnMessageReceived(const IPC::Message& message);
+ virtual bool CanShutdown() { return instances_.empty(); }
+
// Updates the title shown in the task manager.
void UpdateTitle();