| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process/kill.h" | 5 #include "base/process/kill.h" |
| 6 | 6 |
| 7 #include <io.h> | 7 #include <io.h> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // indication that the task manager has killed something if the | 31 // indication that the task manager has killed something if the |
| 32 // process goes away. | 32 // process goes away. |
| 33 const DWORD kProcessKilledExitCode = 1; | 33 const DWORD kProcessKilledExitCode = 1; |
| 34 | 34 |
| 35 // Maximum amount of time (in milliseconds) to wait for the process to exit. | 35 // Maximum amount of time (in milliseconds) to wait for the process to exit. |
| 36 static const int kWaitInterval = 2000; | 36 static const int kWaitInterval = 2000; |
| 37 | 37 |
| 38 class TimerExpiredTask : public win::ObjectWatcher::Delegate { | 38 class TimerExpiredTask : public win::ObjectWatcher::Delegate { |
| 39 public: | 39 public: |
| 40 explicit TimerExpiredTask(Process process); | 40 explicit TimerExpiredTask(Process process); |
| 41 ~TimerExpiredTask(); | 41 ~TimerExpiredTask() override; |
| 42 | 42 |
| 43 void TimedOut(); | 43 void TimedOut(); |
| 44 | 44 |
| 45 // MessageLoop::Watcher ----------------------------------------------------- | 45 // MessageLoop::Watcher ----------------------------------------------------- |
| 46 virtual void OnObjectSignaled(HANDLE object); | 46 void OnObjectSignaled(HANDLE object) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 void KillProcess(); | 49 void KillProcess(); |
| 50 | 50 |
| 51 // The process that we are watching. | 51 // The process that we are watching. |
| 52 Process process_; | 52 Process process_; |
| 53 | 53 |
| 54 win::ObjectWatcher watcher_; | 54 win::ObjectWatcher watcher_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); | 56 DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 MessageLoop::current()->PostDelayedTask( | 191 MessageLoop::current()->PostDelayedTask( |
| 192 FROM_HERE, | 192 FROM_HERE, |
| 193 Bind(&TimerExpiredTask::TimedOut, | 193 Bind(&TimerExpiredTask::TimedOut, |
| 194 Owned(new TimerExpiredTask(process.Pass()))), | 194 Owned(new TimerExpiredTask(process.Pass()))), |
| 195 TimeDelta::FromMilliseconds(kWaitInterval)); | 195 TimeDelta::FromMilliseconds(kWaitInterval)); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace base | 198 } // namespace base |
| OLD | NEW |