Chromium Code Reviews| Index: base/process/kill_win.cc |
| diff --git a/base/process/kill_win.cc b/base/process/kill_win.cc |
| index b102a8781d074337841b794c94267232aa718735..311bdd7c4f714c38fa3a4b44b832a1a3b88d368d 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_; |
|
gab
2014/11/27 13:28:44
If I'm reading this correctly, the changes in this
rvargas (doing something else)
2014/12/01 20:50:36
You're right, there is no need to extend the handl
gab
2014/12/01 21:31:05
Indeed, I meant reset(), not release() (my bad) --
rvargas (doing something else)
2014/12/02 21:07:47
It would be better to not have a Handle method at
|
| 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(); |
| } |
| @@ -75,9 +74,6 @@ void TimerExpiredTask::OnObjectSignaled(HANDLE object) { |
| // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
| tracked_objects::ScopedTracker tracking_profile( |
| FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled")); |
| - |
| - CloseHandle(process_); |
| - process_ = NULL; |
| } |
| void TimerExpiredTask::KillProcess() { |
| @@ -88,10 +84,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 +237,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)); |
| } |