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" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/process/process_iterator.h" | 14 #include "base/process/process_iterator.h" |
15 #include "base/profiler/scoped_profile.h" | 15 #include "base/profiler/scoped_tracker.h" |
16 #include "base/win/object_watcher.h" | 16 #include "base/win/object_watcher.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Exit codes with special meanings on Windows. | 22 // Exit codes with special meanings on Windows. |
23 const DWORD kNormalTerminationExitCode = 0; | 23 const DWORD kNormalTerminationExitCode = 0; |
24 const DWORD kDebuggerInactiveExitCode = 0xC0000354; | 24 const DWORD kDebuggerInactiveExitCode = 0xC0000354; |
25 const DWORD kKeyboardInterruptExitCode = 0xC000013A; | 25 const DWORD kKeyboardInterruptExitCode = 0xC000013A; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 TimedOut(); | 65 TimedOut(); |
66 DCHECK(!process_) << "Make sure to close the handle."; | 66 DCHECK(!process_) << "Make sure to close the handle."; |
67 } | 67 } |
68 | 68 |
69 void TimerExpiredTask::TimedOut() { | 69 void TimerExpiredTask::TimedOut() { |
70 if (process_) | 70 if (process_) |
71 KillProcess(); | 71 KillProcess(); |
72 } | 72 } |
73 | 73 |
74 void TimerExpiredTask::OnObjectSignaled(HANDLE object) { | 74 void TimerExpiredTask::OnObjectSignaled(HANDLE object) { |
75 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 75 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
76 tracked_objects::ScopedProfile tracking_profile( | 76 tracked_objects::ScopedTracker tracking_profile( |
77 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 77 FROM_HERE_WITH_EXPLICIT_FUNCTION("TimerExpiredTask_OnObjectSignaled")); |
78 "TimerExpiredTask_OnObjectSignaled")); | |
79 | 78 |
80 CloseHandle(process_); | 79 CloseHandle(process_); |
81 process_ = NULL; | 80 process_ = NULL; |
82 } | 81 } |
83 | 82 |
84 void TimerExpiredTask::KillProcess() { | 83 void TimerExpiredTask::KillProcess() { |
85 // Stop watching the process handle since we're killing it. | 84 // Stop watching the process handle since we're killing it. |
86 watcher_.StopWatching(); | 85 watcher_.StopWatching(); |
87 | 86 |
88 // OK, time to get frisky. We don't actually care when the process | 87 // OK, time to get frisky. We don't actually care when the process |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 251 } |
253 | 252 |
254 MessageLoop::current()->PostDelayedTask( | 253 MessageLoop::current()->PostDelayedTask( |
255 FROM_HERE, | 254 FROM_HERE, |
256 base::Bind(&TimerExpiredTask::TimedOut, | 255 base::Bind(&TimerExpiredTask::TimedOut, |
257 base::Owned(new TimerExpiredTask(process))), | 256 base::Owned(new TimerExpiredTask(process))), |
258 base::TimeDelta::FromMilliseconds(kWaitInterval)); | 257 base::TimeDelta::FromMilliseconds(kWaitInterval)); |
259 } | 258 } |
260 | 259 |
261 } // namespace base | 260 } // namespace base |
OLD | NEW |