Chromium Code Reviews| 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 |