diff options
author | rosen.dash@gmail.com <rosen.dash@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 19:30:33 +0000 |
---|---|---|
committer | rosen.dash@gmail.com <rosen.dash@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 19:30:33 +0000 |
commit | 35d2dbbb6e5e1acd80e39981d520c0bc7f0abec1 (patch) | |
tree | b6e4613d7bd888c9cb5b4f1c20b27bd10030386b /content | |
parent | cd630dae8c2731af602a4ad6913e394517714c1a (diff) | |
download | chromium_src-35d2dbbb6e5e1acd80e39981d520c0bc7f0abec1.zip chromium_src-35d2dbbb6e5e1acd80e39981d520c0bc7f0abec1.tar.gz chromium_src-35d2dbbb6e5e1acd80e39981d520c0bc7f0abec1.tar.bz2 |
Send the PID of the renderer process that is getting closed in RenderClosedDetails. This helps fixing the leaks where Aw! Snap, He's Dead JIM tabs come and Browser's PID is sent instead of Renderer PID's.
BUG=55734
TEST=None
Patch by: rosen.dash@gmail.com
Review URL: http://codereview.chromium.org/8217005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106758 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
4 files changed, 24 insertions, 9 deletions
diff --git a/content/browser/mach_broker_mac.cc b/content/browser/mach_broker_mac.cc index 6905c7f..85fd3a8 100644 --- a/content/browser/mach_broker_mac.cc +++ b/content/browser/mach_broker_mac.cc @@ -208,6 +208,10 @@ void MachBroker::Observe(int type, base::ProcessHandle handle = 0; switch (type) { case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: + handle = + content::Details<RenderProcessHost::RendererClosedDetails>(details)-> + handle; + break; case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: handle = content::Source<RenderProcessHost>(source)->GetHandle(); break; diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc index f5b10a9..abcb84d 100644 --- a/content/browser/renderer_host/browser_render_process_host.cc +++ b/content/browser/renderer_host/browser_render_process_host.cc @@ -662,8 +662,9 @@ bool BrowserRenderProcessHost::FastShutdownIfPossible() { if (!sudden_termination_allowed()) return false; - child_process_launcher_.reset(); - ProcessDied(base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); + // Store the handle before it gets changed. + base::ProcessHandle handle = GetHandle(); + ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); fast_shutdown_started_ = true; return true; } @@ -828,6 +829,9 @@ void BrowserRenderProcessHost::OnChannelError() { if (!channel_.get()) return; + // Store the handle before it gets changed. + base::ProcessHandle handle = GetHandle(); + // child_process_launcher_ can be NULL in single process mode or if fast // termination happened. int exit_code = 0; @@ -846,30 +850,33 @@ void BrowserRenderProcessHost::OnChannelError() { } } #endif - ProcessDied(status, exit_code, false); + ProcessDied(handle, status, exit_code, false); } // Called when the renderer process handle has been signaled. void BrowserRenderProcessHost::OnWaitableEventSignaled( base::WaitableEvent* waitable_event) { #if defined (OS_WIN) + base::ProcessHandle handle = GetHandle(); int exit_code = 0; base::TerminationStatus status = base::GetTerminationStatus(waitable_event->Release(), &exit_code); delete waitable_event; - ProcessDied(status, exit_code, true); + ProcessDied(handle, status, exit_code, true); #endif } -void BrowserRenderProcessHost::ProcessDied( - base::TerminationStatus status, int exit_code, bool was_alive) { +void BrowserRenderProcessHost::ProcessDied(base::ProcessHandle handle, + base::TerminationStatus status, + int exit_code, + bool was_alive) { // 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. // The OnChannelError notification can fire multiple times due to nested sync // calls to a renderer. If we don't have a valid channel here it means we // already handled the error. - RendererClosedDetails details(status, exit_code, was_alive); + RendererClosedDetails details(handle, status, exit_code, was_alive); content::NotificationService::current()->Notify( content::NOTIFICATION_RENDERER_PROCESS_CLOSED, content::Source<RenderProcessHost>(this), diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/browser_render_process_host.h index 794cc76..21eeda8 100644 --- a/content/browser/renderer_host/browser_render_process_host.h +++ b/content/browser/renderer_host/browser_render_process_host.h @@ -115,7 +115,8 @@ class CONTENT_EXPORT BrowserRenderProcessHost // Handle termination of our process. |was_alive| indicates that when we // tried to retrieve the exit code the process had not finished yet. - void ProcessDied(base::TerminationStatus status, + void ProcessDied(base::ProcessHandle handle, + base::TerminationStatus status, int exit_code, bool was_alive); diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h index 1e752cf..508f093 100644 --- a/content/browser/renderer_host/render_process_host.h +++ b/content/browser/renderer_host/render_process_host.h @@ -48,13 +48,16 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Channel::Sender, // Details for RENDERER_PROCESS_CLOSED notifications. struct RendererClosedDetails { - RendererClosedDetails(base::TerminationStatus status, + RendererClosedDetails(base::ProcessHandle handle, + base::TerminationStatus status, int exit_code, bool was_alive) { + this->handle = handle; this->status = status; this->exit_code = exit_code; this->was_alive = was_alive; } + base::ProcessHandle handle; base::TerminationStatus status; int exit_code; bool was_alive; |