Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: content/browser/browser_child_process_host_impl.cc

Issue 12374061: Windows: BrowserChildProcessHostImpl reports OnProcessCrashed if the child process crashes before… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_child_process_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_child_process_host_impl.cc
===================================================================
--- content/browser/browser_child_process_host_impl.cc (revision 184931)
+++ content/browser/browser_child_process_host_impl.cc (working copy)
@@ -86,6 +86,13 @@
BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() {
g_child_process_list.Get().remove(this);
+
+#if defined(OS_WIN)
+ // The WaitableEvent takes ownership of its handle so release it here to
+ // avoid a double free.
+ if (process_waitable_event_.get())
+ process_waitable_event_->Release();
cpu_(ooo_6.6-7.5) 2013/03/04 22:46:59 call GetWatchedEvent to obtain this?
apatrick_chromium 2013/03/05 00:22:41 Done.
+#endif
}
// static
@@ -206,6 +213,12 @@
void BrowserChildProcessHostImpl::OnChannelConnected(int32 peer_pid) {
Notify(NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED);
delegate_->OnChannelConnected(peer_pid);
+
+#if defined(OS_WIN)
+ // From this point onward, the exit of the child process is detected by an
+ // error on the IPC channel.
+ early_exit_watcher_.StopWatching();
cpu_(ooo_6.6-7.5) 2013/03/04 22:46:59 maybe this ahead of the delegate_ call?
apatrick_chromium 2013/03/05 00:22:41 Done.
+#endif
}
void BrowserChildProcessHostImpl::OnChannelError() {
@@ -264,8 +277,27 @@
delete delegate_; // Will delete us
return;
}
+
+#if defined(OS_WIN)
+ // Start a WaitableEventWatcher that will invoke OnProcessExitedEarly if the
+ // child process exits. This watcher is stopped once the IPC channel is
+ // connected and the exit of the child process is detecter by an error on the
+ // IPC channel thereafter.
+ process_waitable_event_.reset(
cpu_(ooo_6.6-7.5) 2013/03/04 22:46:59 do we really need the process_waitable_event_ as a
apatrick_chromium 2013/03/05 00:22:41 Done.
+ new base::WaitableEvent(child_process_->GetHandle()));
+ early_exit_watcher_.StartWatching(
+ process_waitable_event_.get(),
+ base::Bind(&BrowserChildProcessHostImpl::OnProcessExitedEarly,
+ base::Unretained(this)));
+#endif
+
data_.handle = child_process_->GetHandle();
delegate_->OnProcessLaunched();
}
+void BrowserChildProcessHostImpl::OnProcessExitedEarly(
+ base::WaitableEvent* event) {
+ OnChildDisconnected();
+}
+
} // namespace content
« no previous file with comments | « content/browser/browser_child_process_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698