summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 02:10:16 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-10 02:10:16 +0000
commit7c9a9cb4c16ffa5599eb8cba63109adbfac9b2d0 (patch)
tree470d6add943eb597c40a342062eeb09bb4a3cb16 /chrome
parent3a1abcfe03959dd877ebadcffde373a54fb2c661 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/utility_process_host.cc1
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc1
-rw-r--r--chrome/common/child_process_host.cc33
-rw-r--r--chrome/common/child_process_host.h11
4 files changed, 31 insertions, 15 deletions
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index 84f506a..0d9aaa6 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/file_util.h"
-#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/task.h"
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 017ea86..9672dd1 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/debug_util.h"
-#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/string_util.h"
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();
}
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
index 3b97200..caabe66 100644
--- a/chrome/common/child_process_host.h
+++ b/chrome/common/child_process_host.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
+#include "base/waitable_event_watcher.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/common/ipc_channel.h"
@@ -18,6 +19,7 @@ class NotificationType;
// Plugins/workers and other child processes that live on the IO thread should
// derive from this class.
class ChildProcessHost : public ResourceDispatcherHost::Receiver,
+ public base::WaitableEventWatcher::Delegate,
public IPC::Channel::Listener {
public:
virtual ~ChildProcessHost();
@@ -76,8 +78,8 @@ class ChildProcessHost : public ResourceDispatcherHost::Receiver,
// Sends the given notification to the notification service on the UI thread.
void Notify(NotificationType type);
- // Called when the child process goes away.
- void OnChildDied();
+ // WaitableEventWatcher::Delegate implementation:
+ virtual void OnWaitableEventSignaled(base::WaitableEvent *event);
// By using an internal class as the IPC::Channel::Listener, we can intercept
// OnMessageReceived/OnChannelConnected and do our own processing before
@@ -104,6 +106,11 @@ class ChildProcessHost : public ResourceDispatcherHost::Receiver,
// IPC Channel's id.
std::string channel_id_;
+
+ // Used to watch the child process handle.
+ base::WaitableEventWatcher watcher_;
+
+ scoped_ptr<base::WaitableEvent> process_event_;
};
#endif // CHROME_COMMON_CHILD_PROCESS_HOST_H_