diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 06:31:41 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 06:31:41 +0000 |
commit | aeab4c7449f26ac71546c1419c524c0870bc155a (patch) | |
tree | ba7549cb86473478921b14e00d5ef8e701f7c7f8 /chrome/browser/render_process_host.cc | |
parent | ba7f857605d7d088dff38e6ceab868dd90fc108b (diff) | |
download | chromium_src-aeab4c7449f26ac71546c1419c524c0870bc155a.zip chromium_src-aeab4c7449f26ac71546c1419c524c0870bc155a.tar.gz chromium_src-aeab4c7449f26ac71546c1419c524c0870bc155a.tar.bz2 |
Revised r408 such that we no longer sometimes fail MetricsServiceTest.CrashRenderers.
That test showed that we were exiting the browser process without noticing that a child process had crashed. I fixed that by simply adding a check to see if the child process is still around before initiating the normal close of the child process. This corresponds to the case where the browser decides to close a renderer.
As a result, the race for the MessageLoop to receive a Task notifying the RenderProcessHost of a crashed renderer is removed from the picture.
The bulk of this CL is just re-landing r408, which jar reviewed.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/render_process_host.cc')
-rw-r--r-- | chrome/browser/render_process_host.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc index 43ebb64..3dea5c0 100644 --- a/chrome/browser/render_process_host.cc +++ b/chrome/browser/render_process_host.cc @@ -202,7 +202,7 @@ RenderProcessHost::~RenderProcessHost() { channel_.reset(); if (process_.handle() && !run_renderer_in_process_) { - MessageLoop::current()->WatchObject(process_.handle(), NULL); + watcher_.StopWatching(); ProcessWatcher::EnsureProcessTerminated(process_.handle()); } @@ -420,7 +420,7 @@ bool RenderProcessHost::Init() { process_.set_handle(process); } - MessageLoop::current()->WatchObject(process_.handle(), this); + watcher_.StartWatching(process_.handle(), this); } } @@ -459,16 +459,18 @@ void RenderProcessHost::Release(int listener_id) { DCHECK(listeners_.Lookup(listener_id) != NULL); listeners_.Remove(listener_id); - // make sure that all associated resource requests are stopped. + // Make sure that all associated resource requests are stopped. widget_helper_->CancelResourceRequests(listener_id); - // when no other owners of this object, we can delete ourselves + // When there are no other owners of this object, we can delete ourselves. if (listeners_.IsEmpty()) { if (!notified_termination_) { - bool close_expected = true; + // It is possible that the renderer died already even though we haven't + // broken the pipe yet. We should take care to count this as unexpected. + bool clean_shutdown = !process_util::DidProcessCrash(process_.handle()); NotificationService::current()->Notify(NOTIFY_RENDERER_PROCESS_TERMINATED, Source<RenderProcessHost>(this), - Details<bool>(&close_expected)); + Details<bool>(&clean_shutdown)); notified_termination_ = true; } Unregister(); @@ -506,8 +508,8 @@ bool RenderProcessHost::FastShutdownIfPossible() { return false; } } - // Otherwise, call TerminateProcess. Using exit code 0 means that UMA won't - // treat this as a renderer crash. + // Otherwise, call TerminateProcess. Using NORMAL_EXIT here means that UMA + // won't treat this as a renderer crash. ::TerminateProcess(proc, ResultCodes::NORMAL_EXIT); return true; } @@ -576,7 +578,7 @@ void RenderProcessHost::OnChannelConnected(int32 peer_pid) { // returned by CreateProcess() has to the process object. process_.set_handle(OpenProcess(MAXIMUM_ALLOWED, FALSE, peer_pid)); DCHECK(process_.handle()); - MessageLoop::current()->WatchObject(process_.handle(), this); + watcher_.StartWatching(process_.handle(), this); } } else { // Need to verify that the peer_pid is actually the process we know, if @@ -591,8 +593,6 @@ void RenderProcessHost::OnObjectSignaled(HANDLE object) { DCHECK(channel_.get()); DCHECK_EQ(object, process_.handle()); - MessageLoop::current()->WatchObject(object, NULL); - bool clean_shutdown = !process_util::DidProcessCrash(object); process_.Close(); @@ -600,8 +600,8 @@ void RenderProcessHost::OnObjectSignaled(HANDLE object) { channel_.reset(); if (!notified_termination_) { - // If |close_expected| is false, it means the renderer process went away - // before the web views expected it; count it as a crash. + // If |clean_shutdown| is false, it means the renderer process went away + // before we expected it; count it as a crash. NotificationService::current()->Notify(NOTIFY_RENDERER_PROCESS_TERMINATED, Source<RenderProcessHost>(this), Details<bool>(&clean_shutdown)); |