diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 02:10:16 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 02:10:16 +0000 |
commit | 7c9a9cb4c16ffa5599eb8cba63109adbfac9b2d0 (patch) | |
tree | 470d6add943eb597c40a342062eeb09bb4a3cb16 /chrome/common/child_process_host.cc | |
parent | 3a1abcfe03959dd877ebadcffde373a54fb2c661 (diff) | |
download | chromium_src-7c9a9cb4c16ffa5599eb8cba63109adbfac9b2d0.zip chromium_src-7c9a9cb4c16ffa5599eb8cba63109adbfac9b2d0.tar.gz chromium_src-7c9a9cb4c16ffa5599eb8cba63109adbfac9b2d0.tar.bz2 |
Revert "plugins: use OnChannelError to detect when the channel goes away"
This reverts commit r20349.
Unit test failure. I suspect the test, but let's keep the tree green.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20354 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_process_host.cc')
-rw-r--r-- | chrome/common/child_process_host.cc | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc index 67d9a5a..c2c925e 100644 --- a/chrome/common/child_process_host.cc +++ b/chrome/common/child_process_host.cc @@ -51,7 +51,8 @@ ChildProcessHost::ChildProcessHost( : Receiver(type), ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)), resource_dispatcher_host_(resource_dispatcher_host), - opening_channel_(false) { + opening_channel_(false), + process_event_(NULL) { Singleton<ChildProcessList>::get()->push_back(this); } @@ -61,8 +62,16 @@ ChildProcessHost::~ChildProcessHost() { resource_dispatcher_host_->CancelRequestsForProcess(GetProcessId()); - if (handle()) + if (handle()) { + watcher_.StopWatching(); ProcessWatcher::EnsureProcessTerminated(handle()); + +#if defined(OS_WIN) + // Above call took ownership, so don't want WaitableEvent to assert because + // the handle isn't valid anymore. + process_event_->Release(); +#endif + } } bool ChildProcessHost::CreateChannel() { @@ -78,8 +87,13 @@ bool ChildProcessHost::CreateChannel() { } void ChildProcessHost::SetHandle(base::ProcessHandle process) { +#if defined(OS_WIN) + process_event_.reset(new base::WaitableEvent(process)); + DCHECK(!handle()); set_handle(process); + watcher_.StartWatching(process_event_.get(), this); +#endif } void ChildProcessHost::InstanceCreated() { @@ -99,20 +113,20 @@ void ChildProcessHost::Notify(NotificationType type) { FROM_HERE, new ChildNotificationTask(type, this)); } -void ChildProcessHost::OnChildDied() { +void ChildProcessHost::OnWaitableEventSignaled(base::WaitableEvent *event) { +#if defined(OS_WIN) + HANDLE object = event->handle(); DCHECK(handle()); + DCHECK_EQ(object, handle()); - bool did_crash = base::DidProcessCrash(NULL, handle()); + bool did_crash = base::DidProcessCrash(NULL, object); if (did_crash) { // Report that this child process crashed. Notify(NotificationType::CHILD_PROCESS_CRASHED); } // Notify in the main loop of the disconnection. Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED); - - // On POSIX, once we've called DidProcessCrash, handle() is no longer - // valid. Ensure the destructor doesn't try to use it. - set_handle(NULL); +#endif delete this; } @@ -171,9 +185,6 @@ void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { void ChildProcessHost::ListenerHook::OnChannelError() { host_->opening_channel_ = false; host_->OnChannelError(); - - // This will delete host_, which will also destroy this! - host_->OnChildDied(); } |