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

Unified Diff: base/process/kill_win.cc

Issue 759903002: Upgrade the windows specific version of LaunchProcess to avoid raw handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix chrome build 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 b102a8781d074337841b794c94267232aa718735..0a0c99c854276a3b2b1b141ee0ecccaabd876062 100644
--- a/base/process/kill_win.cc
+++ b/base/process/kill_win.cc
@@ -38,7 +38,7 @@ static const int kWaitInterval = 2000;
class TimerExpiredTask : public win::ObjectWatcher::Delegate {
public:
- explicit TimerExpiredTask(ProcessHandle process);
+ explicit TimerExpiredTask(Process process);
~TimerExpiredTask();
void TimedOut();
@@ -50,24 +50,23 @@ class TimerExpiredTask : public win::ObjectWatcher::Delegate {
void KillProcess();
// The process that we are watching.
- ProcessHandle process_;
+ Process process_;
win::ObjectWatcher watcher_;
DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask);
};
-TimerExpiredTask::TimerExpiredTask(ProcessHandle process) : process_(process) {
- watcher_.StartWatching(process_, this);
+TimerExpiredTask::TimerExpiredTask(Process process) : process_(process.Pass()) {
+ watcher_.StartWatching(process_.Handle(), this);
}
TimerExpiredTask::~TimerExpiredTask() {
TimedOut();
- DCHECK(!process_) << "Make sure to close the handle.";
}
void TimerExpiredTask::TimedOut() {
- if (process_)
+ if (process_.IsValid())
KillProcess();
}
@@ -76,8 +75,7 @@ void TimerExpiredTask::OnObjectSignaled(HANDLE object) {
tracked_objects::ScopedTracker tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled"));
- CloseHandle(process_);
- process_ = NULL;
+ process_.Close();
}
void TimerExpiredTask::KillProcess() {
@@ -88,10 +86,10 @@ void TimerExpiredTask::KillProcess() {
// 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_, kProcessKilledExitCode, false);
+ base::KillProcess(process_.Handle(), kProcessKilledExitCode, false);
// Now, just cleanup as if the process exited normally.
- OnObjectSignaled(process_);
+ OnObjectSignaled(process_.Handle());
}
} // namespace
@@ -241,19 +239,18 @@ bool CleanupProcesses(const FilePath::StringType& executable_name,
return false;
}
-void EnsureProcessTerminated(ProcessHandle process) {
- DCHECK(process != GetCurrentProcess());
+void EnsureProcessTerminated(Process process) {
+ DCHECK(!process.is_current());
// If already signaled, then we are done!
- if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) {
- CloseHandle(process);
+ if (WaitForSingleObject(process.Handle(), 0) == WAIT_OBJECT_0) {
return;
}
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&TimerExpiredTask::TimedOut,
- base::Owned(new TimerExpiredTask(process))),
+ base::Owned(new TimerExpiredTask(process.Pass()))),
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