diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 20:23:36 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 20:23:36 +0000 |
commit | 3131a4bc3ef3b6f545b7dea6ea55d8419099b7b2 (patch) | |
tree | fef3b85252836c1afe7c354ba9a6e5766d8402ac /chrome/browser/renderer_host | |
parent | fcc2caa7b147a296f450df1d3bbcd2bc4569093e (diff) | |
download | chromium_src-3131a4bc3ef3b6f545b7dea6ea55d8419099b7b2.zip chromium_src-3131a4bc3ef3b6f545b7dea6ea55d8419099b7b2.tar.gz chromium_src-3131a4bc3ef3b6f545b7dea6ea55d8419099b7b2.tar.bz2 |
Fix race in zygote_host_linux where socket was being read from and written to on different threads.
Made ZygoteHost methods all run on PROCESS_LAUNCHER thread. PostTask in linux from UI thread to PROCESS_LAUNCHER thread for DidProcessCrash. Changed DidProcessCrash to answer via a callback, which occurs asynchronously on linux. Rework cases in nacl_host, browser_render_process_host, and child_process_host where this method was being called to fit the callback model.
BUG=31737
TEST=none
Review URL: http://codereview.chromium.org/1695026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
3 files changed, 28 insertions, 22 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index fff6622..f7fb092 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -860,23 +860,12 @@ void BrowserRenderProcessHost::OnChannelError() { if (!channel_.get()) return; - // NULL in single process mode or if fast termination happened. - bool did_crash = - child_process_.get() ? child_process_->DidProcessCrash() : false; - - if (did_crash) { - UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", - extension_process_ ? 2 : 1); - } - - RendererClosedDetails details(did_crash, extension_process_); NotificationService::current()->Notify( NotificationType::RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), - Details<RendererClosedDetails>(&details)); + NotificationService::NoDetails()); WebCacheManager::GetInstance()->Remove(id()); - child_process_.reset(); channel_.reset(); IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); @@ -888,6 +877,32 @@ void BrowserRenderProcessHost::OnChannelError() { ClearTransportDIBCache(); + if (child_process_.get()) { + // Determine whether the process crashed or not. This method will invoke + // OnDidProcessCrashDetermined with the result. This may occur + // asynchronously. + child_process_->DetermineDidProcessCrash(); + } else { + // This occurs in single process mode or if fast termination happened. + // Manually trigger OnDidProcessCrashDetermined, because we know this is + // not a crash. + OnDidProcessCrashDetermined(false); + } +} + +void BrowserRenderProcessHost::OnDidProcessCrashDetermined(bool did_crash) { + child_process_.reset(); + + if (did_crash) { + UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", + extension_process_ ? 2 : 1); + + NotificationService::current()->Notify( + NotificationType::RENDERER_PROCESS_CRASHED, + Source<RenderProcessHost>(this), + Details<bool>(&extension_process_)); + } + // this object is not deleted at this point and may be reused later. // TODO(darin): clean this up } diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index 2a7f8b6..00c2a02 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -100,6 +100,7 @@ class BrowserRenderProcessHost : public RenderProcessHost, // ChildProcessLauncher::Client implementation. virtual void OnProcessLaunched(); + virtual void OnDidProcessCrashDetermined(bool did_crash); private: friend class VisitRelayingRenderProcessHost; diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h index 1ceeb42..1eb9804 100644 --- a/chrome/browser/renderer_host/render_process_host.h +++ b/chrome/browser/renderer_host/render_process_host.h @@ -46,16 +46,6 @@ class RenderProcessHost : public IPC::Channel::Sender, TYPE_EXTENSION, // Renderer with extension privileges. }; - // Details for RENDERER_PROCESS_CLOSED notifications. - struct RendererClosedDetails { - RendererClosedDetails(bool did_crash, bool was_extension_renderer) { - this->did_crash = did_crash; - this->was_extension_renderer = was_extension_renderer; - } - bool did_crash; - bool was_extension_renderer; - }; - explicit RenderProcessHost(Profile* profile); virtual ~RenderProcessHost(); |