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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const ProcessFilter* filter) { | 152 const ProcessFilter* filter) { |
153 bool result = true; | 153 bool result = true; |
154 DWORD start_time = GetTickCount(); | 154 DWORD start_time = GetTickCount(); |
155 | 155 |
156 NamedProcessIterator iter(executable_name, filter); | 156 NamedProcessIterator iter(executable_name, filter); |
157 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry; | 157 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry; |
158 entry = iter.NextProcessEntry()) { | 158 entry = iter.NextProcessEntry()) { |
159 DWORD remaining_wait = static_cast<DWORD>(std::max( | 159 DWORD remaining_wait = static_cast<DWORD>(std::max( |
160 static_cast<int64>(0), | 160 static_cast<int64>(0), |
161 wait.InMilliseconds() - (GetTickCount() - start_time))); | 161 wait.InMilliseconds() - (GetTickCount() - start_time))); |
162 Process process(Process::OpenWithAccess(entry->th32ProcessID, SYNCHRONIZE)); | 162 HANDLE process = OpenProcess(SYNCHRONIZE, |
163 DWORD wait_result = WaitForSingleObject(process.Handle(), remaining_wait); | 163 FALSE, |
| 164 entry->th32ProcessID); |
| 165 DWORD wait_result = WaitForSingleObject(process, remaining_wait); |
| 166 CloseHandle(process); |
164 result &= (wait_result == WAIT_OBJECT_0); | 167 result &= (wait_result == WAIT_OBJECT_0); |
165 } | 168 } |
166 | 169 |
167 return result; | 170 return result; |
168 } | 171 } |
169 | 172 |
170 bool CleanupProcesses(const FilePath::StringType& executable_name, | 173 bool CleanupProcesses(const FilePath::StringType& executable_name, |
171 TimeDelta wait, | 174 TimeDelta wait, |
172 int exit_code, | 175 int exit_code, |
173 const ProcessFilter* filter) { | 176 const ProcessFilter* filter) { |
(...skipping 12 matching lines...) Expand all Loading... |
186 } | 189 } |
187 | 190 |
188 MessageLoop::current()->PostDelayedTask( | 191 MessageLoop::current()->PostDelayedTask( |
189 FROM_HERE, | 192 FROM_HERE, |
190 Bind(&TimerExpiredTask::TimedOut, | 193 Bind(&TimerExpiredTask::TimedOut, |
191 Owned(new TimerExpiredTask(process.Pass()))), | 194 Owned(new TimerExpiredTask(process.Pass()))), |
192 TimeDelta::FromMilliseconds(kWaitInterval)); | 195 TimeDelta::FromMilliseconds(kWaitInterval)); |
193 } | 196 } |
194 | 197 |
195 } // namespace base | 198 } // namespace base |
OLD | NEW |