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 base::win::ScopedHandle process(OpenProcess(SYNCHRONIZE, |
grt (UTC plus 2)
2015/09/16 15:30:33
Process process(Process::OpenWithAccess(entry->th3
brucedawson
2015/09/16 18:29:00
Done.
| |
163 FALSE, | 163 FALSE, |
164 entry->th32ProcessID); | 164 entry->th32ProcessID)); |
165 DWORD wait_result = WaitForSingleObject(process, remaining_wait); | 165 DWORD wait_result = WaitForSingleObject(process.Get(), remaining_wait); |
grt (UTC plus 2)
2015/09/16 15:30:33
process.Handle()
grt (UTC plus 2)
2015/09/16 15:30:33
should this check process.IsValid() before trying
brucedawson
2015/09/16 18:29:00
Done.
brucedawson
2015/09/16 18:29:00
That seems like a separate change - I'm not sure w
grt (UTC plus 2)
2015/09/16 19:27:01
I assume Wait will fail with an error if the handl
| |
166 CloseHandle(process); | |
167 result &= (wait_result == WAIT_OBJECT_0); | 166 result &= (wait_result == WAIT_OBJECT_0); |
168 } | 167 } |
169 | 168 |
170 return result; | 169 return result; |
171 } | 170 } |
172 | 171 |
173 bool CleanupProcesses(const FilePath::StringType& executable_name, | 172 bool CleanupProcesses(const FilePath::StringType& executable_name, |
174 TimeDelta wait, | 173 TimeDelta wait, |
175 int exit_code, | 174 int exit_code, |
176 const ProcessFilter* filter) { | 175 const ProcessFilter* filter) { |
(...skipping 12 matching lines...) Expand all Loading... | |
189 } | 188 } |
190 | 189 |
191 MessageLoop::current()->PostDelayedTask( | 190 MessageLoop::current()->PostDelayedTask( |
192 FROM_HERE, | 191 FROM_HERE, |
193 Bind(&TimerExpiredTask::TimedOut, | 192 Bind(&TimerExpiredTask::TimedOut, |
194 Owned(new TimerExpiredTask(process.Pass()))), | 193 Owned(new TimerExpiredTask(process.Pass()))), |
195 TimeDelta::FromMilliseconds(kWaitInterval)); | 194 TimeDelta::FromMilliseconds(kWaitInterval)); |
196 } | 195 } |
197 | 196 |
198 } // namespace base | 197 } // namespace base |
OLD | NEW |