diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 23:36:23 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 23:36:23 +0000 |
commit | 971c16885e6dca38e4f3d5d5ba5b73214e3526e7 (patch) | |
tree | df8db75694b66ac673f8b98dfedf1ef509c1994a /chrome/browser/renderer_host | |
parent | e9e3ffdd0c69ecb48c656bd9bd61a10beb731091 (diff) | |
download | chromium_src-971c16885e6dca38e4f3d5d5ba5b73214e3526e7.zip chromium_src-971c16885e6dca38e4f3d5d5ba5b73214e3526e7.tar.gz chromium_src-971c16885e6dca38e4f3d5d5ba5b73214e3526e7.tar.bz2 |
Retry r27137. Create renderers for ExtensionHosts one at a time to avoid blocking the UI.
I added a process.Close() to the fast shutdown path for renderers. The problem
was that we were trying to use an old terminated process handle.
BUG=14040
TEST=Install a bunch of extensions with toolstrips, then restart Chrome. The
UI should be responsive while the toolstrips are loading.
Review URL: http://codereview.chromium.org/243007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 20 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.h | 3 |
2 files changed, 18 insertions, 5 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 4276efa..676f8ce 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -195,7 +195,8 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( base::TimeDelta::FromSeconds(5), this, &BrowserRenderProcessHost::ClearTransportDIBCache)), - zygote_child_(false) { + zygote_child_(false), + fast_shutdown_(false) { widget_helper_ = new RenderWidgetHelper(); registrar_.Add(this, NotificationType::USER_SCRIPTS_UPDATED, @@ -442,6 +443,7 @@ bool BrowserRenderProcessHost::Init() { return false; } process_.set_handle(process); + fast_shutdown_ = false; // Log the launch time, separating out the first one (which will likely be // slower due to the rest of the browser initializing at the same time). @@ -637,6 +639,8 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() { // Otherwise, we're allowed to just terminate the process. Using exit code 0 // means that UMA won't treat this as a renderer crash. process_.Terminate(ResultCodes::NORMAL_EXIT); + process_.Close(); + fast_shutdown_ = true; return true; } @@ -763,7 +767,11 @@ void BrowserRenderProcessHost::OnMessageReceived(const IPC::Message& msg) { void BrowserRenderProcessHost::OnChannelConnected(int32 peer_pid) { // process_ is not NULL if we created the renderer process if (!process_.handle()) { - if (base::GetCurrentProcId() == peer_pid) { + if (fast_shutdown_) { + // We terminated the process, but the ChannelConnected task was still + // in the queue. We can safely ignore it. + return; + } else if (base::GetCurrentProcId() == peer_pid) { // We are in single-process mode. In theory we should have access to // ourself but it may happen that we don't. process_.set_handle(base::GetCurrentProcessHandle()); @@ -818,13 +826,15 @@ void BrowserRenderProcessHost::BadMessageTerminateProcess( void BrowserRenderProcessHost::OnChannelError() { // Our child process has died. If we didn't expect it, it's a crash. // In any case, we need to let everyone know it's gone. - - DCHECK(process_.handle()); DCHECK(channel_.get()); bool child_exited; bool did_crash; - if (zygote_child_) { + if (!process_.handle()) { + // The process has been terminated (likely FastShutdownIfPossible). + did_crash = false; + child_exited = true; + } else if (zygote_child_) { #if defined(OS_LINUX) did_crash = Singleton<ZygoteHost>()->DidProcessCrash( process_.handle(), &child_exited); diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index b8a5c54..556ba05 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -166,6 +166,9 @@ class BrowserRenderProcessHost : public RenderProcessHost, // True iff the renderer is a child of a zygote process. bool zygote_child_; + // True if FastShutdownIfPossible was called and was successful. + bool fast_shutdown_; + DISALLOW_COPY_AND_ASSIGN(BrowserRenderProcessHost); }; |