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 <windows.h> |
7 #include <io.h> | 8 #include <io.h> |
8 #include <windows.h> | 9 #include <stdint.h> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
14 #include "base/process/process_iterator.h" | 16 #include "base/process/process_iterator.h" |
15 #include "base/win/object_watcher.h" | 17 #include "base/win/object_watcher.h" |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // Exit codes with special meanings on Windows. | 23 // Exit codes with special meanings on Windows. |
22 const DWORD kNormalTerminationExitCode = 0; | 24 const DWORD kNormalTerminationExitCode = 0; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 151 |
150 bool WaitForProcessesToExit(const FilePath::StringType& executable_name, | 152 bool WaitForProcessesToExit(const FilePath::StringType& executable_name, |
151 TimeDelta wait, | 153 TimeDelta wait, |
152 const ProcessFilter* filter) { | 154 const ProcessFilter* filter) { |
153 bool result = true; | 155 bool result = true; |
154 DWORD start_time = GetTickCount(); | 156 DWORD start_time = GetTickCount(); |
155 | 157 |
156 NamedProcessIterator iter(executable_name, filter); | 158 NamedProcessIterator iter(executable_name, filter); |
157 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry; | 159 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry; |
158 entry = iter.NextProcessEntry()) { | 160 entry = iter.NextProcessEntry()) { |
159 DWORD remaining_wait = static_cast<DWORD>(std::max( | 161 DWORD remaining_wait = static_cast<DWORD>( |
160 static_cast<int64>(0), | 162 std::max(static_cast<int64_t>(0), |
161 wait.InMilliseconds() - (GetTickCount() - start_time))); | 163 wait.InMilliseconds() - (GetTickCount() - start_time))); |
162 HANDLE process = OpenProcess(SYNCHRONIZE, | 164 HANDLE process = OpenProcess(SYNCHRONIZE, |
163 FALSE, | 165 FALSE, |
164 entry->th32ProcessID); | 166 entry->th32ProcessID); |
165 DWORD wait_result = WaitForSingleObject(process, remaining_wait); | 167 DWORD wait_result = WaitForSingleObject(process, remaining_wait); |
166 CloseHandle(process); | 168 CloseHandle(process); |
167 result &= (wait_result == WAIT_OBJECT_0); | 169 result &= (wait_result == WAIT_OBJECT_0); |
168 } | 170 } |
169 | 171 |
170 return result; | 172 return result; |
171 } | 173 } |
(...skipping 17 matching lines...) Expand all Loading... |
189 } | 191 } |
190 | 192 |
191 MessageLoop::current()->PostDelayedTask( | 193 MessageLoop::current()->PostDelayedTask( |
192 FROM_HERE, | 194 FROM_HERE, |
193 Bind(&TimerExpiredTask::TimedOut, | 195 Bind(&TimerExpiredTask::TimedOut, |
194 Owned(new TimerExpiredTask(process.Pass()))), | 196 Owned(new TimerExpiredTask(process.Pass()))), |
195 TimeDelta::FromMilliseconds(kWaitInterval)); | 197 TimeDelta::FromMilliseconds(kWaitInterval)); |
196 } | 198 } |
197 | 199 |
198 } // namespace base | 200 } // namespace base |
OLD | NEW |