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

Unified Diff: base/process/kill_win.cc

Issue 780653003: Revert of Upgrade the windows specific version of LaunchProcess to avoid raw handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « base/process/kill_posix.cc ('k') | base/process/launch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/kill_win.cc
diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc
index 0a0c99c854276a3b2b1b141ee0ecccaabd876062..b102a8781d074337841b794c94267232aa718735 100644
--- a/base/process/kill_win.cc
+++ b/base/process/kill_win.cc
@@ -38,7 +38,7 @@
class TimerExpiredTask : public win::ObjectWatcher::Delegate {
public:
- explicit TimerExpiredTask(Process process);
+ explicit TimerExpiredTask(ProcessHandle process);
~TimerExpiredTask();
void TimedOut();
@@ -50,23 +50,24 @@
void KillProcess();
// The process that we are watching.
- Process process_;
+ ProcessHandle process_;
win::ObjectWatcher watcher_;
DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask);
};
-TimerExpiredTask::TimerExpiredTask(Process process) : process_(process.Pass()) {
- watcher_.StartWatching(process_.Handle(), this);
+TimerExpiredTask::TimerExpiredTask(ProcessHandle process) : process_(process) {
+ watcher_.StartWatching(process_, this);
}
TimerExpiredTask::~TimerExpiredTask() {
TimedOut();
+ DCHECK(!process_) << "Make sure to close the handle.";
}
void TimerExpiredTask::TimedOut() {
- if (process_.IsValid())
+ if (process_)
KillProcess();
}
@@ -75,7 +76,8 @@
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled"));
- process_.Close();
+ CloseHandle(process_);
+ process_ = NULL;
}
void TimerExpiredTask::KillProcess() {
@@ -86,10 +88,10 @@
// 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.
- base::KillProcess(process_.Handle(), kProcessKilledExitCode, false);
+ base::KillProcess(process_, kProcessKilledExitCode, false);
// Now, just cleanup as if the process exited normally.
- OnObjectSignaled(process_.Handle());
+ OnObjectSignaled(process_);
}
} // namespace
@@ -239,18 +241,19 @@
return false;
}
-void EnsureProcessTerminated(Process process) {
- DCHECK(!process.is_current());
+void EnsureProcessTerminated(ProcessHandle process) {
+ DCHECK(process != GetCurrentProcess());
// If already signaled, then we are done!
- if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0) {
+ if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {
+ CloseHandle(process);
return;
}
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&TimerExpiredTask::TimedOut,
- base::Owned(new TimerExpiredTask(process.Pass()))),
+ base::Owned(new TimerExpiredTask(process))),
base::TimeDelta::FromMilliseconds(kWaitInterval));
}
« no previous file with comments | « base/process/kill_posix.cc ('k') | base/process/launch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698