summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 20:01:19 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-23 20:01:19 +0000
commit30dce773eb5fcd940ade62bdb8da8bd86b539744 (patch)
tree7a0474bfa7282c1c35a30ec57141a74b37a06dad /chrome/common
parent65333c20ddb320cc0b5f5fd377d2a870f0e442fc (diff)
downloadchromium_src-30dce773eb5fcd940ade62bdb8da8bd86b539744.zip
chromium_src-30dce773eb5fcd940ade62bdb8da8bd86b539744.tar.gz
chromium_src-30dce773eb5fcd940ade62bdb8da8bd86b539744.tar.bz2
Revert r8560 due to broken interactive_ui_tests
Review URL: http://codereview.chromium.org/18722 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/common.scons7
-rw-r--r--chrome/common/process_watcher.cc78
-rw-r--r--chrome/common/security_filter_peer.h2
3 files changed, 47 insertions, 40 deletions
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index 8761002..7f2fd74 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -218,8 +218,13 @@ if not env.Bit('windows'):
'gfx/icon_util.cc',
'gfx/path.cc',
'ipc_logging.cc',
+ 'jstemplate_builder.cc',
'os_exchange_data.cc',
'plugin_messages.cc',
+ 'process_watcher.cc',
+ 'security_filter_peer.cc',
+ 'win_safe_util.cc',
+ 'win_util.cc',
)
if not env.Bit('windows'):
@@ -230,8 +235,6 @@ if not env.Bit('windows'):
'gfx/chrome_font_win.cc',
'ipc_channel_win.cc',
'resource_bundle_win.cc',
- 'win_safe_util.cc',
- 'win_util.cc',
'$CHROME_DIR/tools/build/win/precompiled$OBJSUFFIX',
)
diff --git a/chrome/common/process_watcher.cc b/chrome/common/process_watcher.cc
index ceabaea2..b43e2db 100644
--- a/chrome/common/process_watcher.cc
+++ b/chrome/common/process_watcher.cc
@@ -4,13 +4,9 @@
#include "chrome/common/process_watcher.h"
-#include "base/basictypes.h"
#include "base/message_loop.h"
-#include "base/process.h"
-#include "base/process_util.h"
+#include "base/object_watcher.h"
#include "base/sys_info.h"
-#include "base/timer.h"
-#include "base/worker_pool.h"
#include "chrome/app/result_codes.h"
#include "chrome/common/env_vars.h"
@@ -19,72 +15,80 @@ static const int kWaitInterval = 2000;
namespace {
-class TerminatorTask : public Task {
+class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
public:
- explicit TerminatorTask(base::ProcessHandle process) : process_(process) {
- timer_.Start(base::TimeDelta::FromMilliseconds(kWaitInterval),
- this, &TerminatorTask::KillProcess);
+ explicit TimerExpiredTask(base::ProcessHandle process) : process_(process) {
+ watcher_.StartWatching(process_, this);
}
- virtual ~TerminatorTask() {
+ virtual ~TimerExpiredTask() {
if (process_) {
KillProcess();
- DCHECK(!process_);
+ DCHECK(!process_) << "Make sure to close the handle.";
}
}
+ // Task ---------------------------------------------------------------------
+
virtual void Run() {
- base::WaitForSingleProcess(process_, kWaitInterval);
- timer_.Stop();
if (process_)
KillProcess();
}
+ // MessageLoop::Watcher -----------------------------------------------------
+
+ virtual void OnObjectSignaled(HANDLE object) {
+ // When we're called from KillProcess, the ObjectWatcher may still be
+ // watching. the process handle, so make sure it has stopped.
+ watcher_.StopWatching();
+
+ CloseHandle(process_);
+ process_ = NULL;
+ }
+
private:
void KillProcess() {
if (base::SysInfo::HasEnvVar(env_vars::kHeadless)) {
- // If running the distributed tests, give the renderer a little time
- // to figure out that the channel is shutdown and unwind.
- if (base::WaitForSingleProcess(process_, kWaitInterval)) {
- Cleanup();
- return;
- }
+ // If running the distributed tests, give the renderer a little time
+ // to figure out that the channel is shutdown and unwind.
+ if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) {
+ OnObjectSignaled(process_);
+ return;
+ }
}
// OK, time to get frisky. We don't actually care when the process
- // terminates. We just care that it eventually terminates.
- base::KillProcess(base::Process(process_).pid(),
- ResultCodes::HUNG,
- false /* don't wait */);
+ // terminates. We just care that it eventually terminates, and that's what
+ // TerminateProcess should do for us. Don't check for the result code since
+ // it fails quite often. This should be investigated eventually.
+ TerminateProcess(process_, ResultCodes::HUNG);
- Cleanup();
- }
-
- void Cleanup() {
- timer_.Stop();
- base::CloseProcessHandle(process_);
- process_ = NULL;
+ // Now, just cleanup as if the process exited normally.
+ OnObjectSignaled(process_);
}
// The process that we are watching.
base::ProcessHandle process_;
- base::OneShotTimer<TerminatorTask> timer_;
+ base::ObjectWatcher watcher_;
- DISALLOW_COPY_AND_ASSIGN(TerminatorTask);
+ DISALLOW_EVIL_CONSTRUCTORS(TimerExpiredTask);
};
} // namespace
// static
void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) {
- DCHECK(base::GetProcId(process) != base::GetCurrentProcId());
+ DCHECK(process != GetCurrentProcess());
- // Check if the process has already exited.
- if (base::WaitForSingleProcess(process, 0)) {
- base::CloseProcessHandle(process);
+ // If already signaled, then we are done!
+ if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {
+ CloseHandle(process);
return;
}
- WorkerPool::PostTask(FROM_HERE, new TerminatorTask(process), true);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ new TimerExpiredTask(process),
+ kWaitInterval);
}
+
diff --git a/chrome/common/security_filter_peer.h b/chrome/common/security_filter_peer.h
index ef19b71..616680d 100644
--- a/chrome/common/security_filter_peer.h
+++ b/chrome/common/security_filter_peer.h
@@ -50,8 +50,8 @@ class SecurityFilterPeer : public webkit_glue::ResourceLoaderBridge::Peer {
SecurityFilterPeer(webkit_glue::ResourceLoaderBridge* resource_loader_bridge,
webkit_glue::ResourceLoaderBridge::Peer* peer);
- webkit_glue::ResourceLoaderBridge::Peer* original_peer_;
webkit_glue::ResourceLoaderBridge* resource_loader_bridge_;
+ webkit_glue::ResourceLoaderBridge::Peer* original_peer_;
private:
DISALLOW_EVIL_CONSTRUCTORS(SecurityFilterPeer);