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 HANDLE process = OpenProcess(SYNCHRONIZE, | 162 Process process(Process::OpenWithAccess(entry->th32ProcessID, SYNCHRONIZE)); |
163 FALSE, | 163 DWORD wait_result = WaitForSingleObject(process.Handle(), remaining_wait); |
164 entry->th32ProcessID); | |
165 DWORD wait_result = WaitForSingleObject(process, remaining_wait); | |
166 CloseHandle(process); | |
167 result &= (wait_result == WAIT_OBJECT_0); | 164 result &= (wait_result == WAIT_OBJECT_0); |
168 } | 165 } |
169 | 166 |
170 return result; | 167 return result; |
171 } | 168 } |
172 | 169 |
173 bool CleanupProcesses(const FilePath::StringType& executable_name, | 170 bool CleanupProcesses(const FilePath::StringType& executable_name, |
174 TimeDelta wait, | 171 TimeDelta wait, |
175 int exit_code, | 172 int exit_code, |
176 const ProcessFilter* filter) { | 173 const ProcessFilter* filter) { |
(...skipping 12 matching lines...) Expand all Loading... |
189 } | 186 } |
190 | 187 |
191 MessageLoop::current()->PostDelayedTask( | 188 MessageLoop::current()->PostDelayedTask( |
192 FROM_HERE, | 189 FROM_HERE, |
193 Bind(&TimerExpiredTask::TimedOut, | 190 Bind(&TimerExpiredTask::TimedOut, |
194 Owned(new TimerExpiredTask(process.Pass()))), | 191 Owned(new TimerExpiredTask(process.Pass()))), |
195 TimeDelta::FromMilliseconds(kWaitInterval)); | 192 TimeDelta::FromMilliseconds(kWaitInterval)); |
196 } | 193 } |
197 | 194 |
198 } // namespace base | 195 } // namespace base |
OLD | NEW |