Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: base/process/kill_win.cc

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/numerics/safe_math_impl.h ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { 180 bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
181 bool success = WaitForExitCodeWithTimeout( 181 bool success = WaitForExitCodeWithTimeout(
182 handle, exit_code, base::TimeDelta::FromMilliseconds(INFINITE)); 182 handle, exit_code, base::TimeDelta::FromMilliseconds(INFINITE));
183 CloseProcessHandle(handle); 183 CloseProcessHandle(handle);
184 return success; 184 return success;
185 } 185 }
186 186
187 bool WaitForExitCodeWithTimeout(ProcessHandle handle, 187 bool WaitForExitCodeWithTimeout(ProcessHandle handle,
188 int* exit_code, 188 int* exit_code,
189 base::TimeDelta timeout) { 189 base::TimeDelta timeout) {
190 if (::WaitForSingleObject(handle, timeout.InMilliseconds()) != WAIT_OBJECT_0) 190 if (::WaitForSingleObject(
191 handle, static_cast<DWORD>(timeout.InMilliseconds())) != WAIT_OBJECT_0)
191 return false; 192 return false;
192 DWORD temp_code; // Don't clobber out-parameters in case of failure. 193 DWORD temp_code; // Don't clobber out-parameters in case of failure.
193 if (!::GetExitCodeProcess(handle, &temp_code)) 194 if (!::GetExitCodeProcess(handle, &temp_code))
194 return false; 195 return false;
195 196
196 *exit_code = temp_code; 197 *exit_code = temp_code;
197 return true; 198 return true;
198 } 199 }
199 200
200 bool WaitForProcessesToExit(const FilePath::StringType& executable_name, 201 bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
201 base::TimeDelta wait, 202 base::TimeDelta wait,
202 const ProcessFilter* filter) { 203 const ProcessFilter* filter) {
203 bool result = true; 204 bool result = true;
204 DWORD start_time = GetTickCount(); 205 DWORD start_time = GetTickCount();
205 206
206 NamedProcessIterator iter(executable_name, filter); 207 NamedProcessIterator iter(executable_name, filter);
207 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry; 208 for (const ProcessEntry* entry = iter.NextProcessEntry(); entry;
208 entry = iter.NextProcessEntry()) { 209 entry = iter.NextProcessEntry()) {
209 DWORD remaining_wait = std::max<int64>( 210 DWORD remaining_wait = static_cast<DWORD>(std::max(
210 0, wait.InMilliseconds() - (GetTickCount() - start_time)); 211 static_cast<int64>(0),
212 wait.InMilliseconds() - (GetTickCount() - start_time)));
211 HANDLE process = OpenProcess(SYNCHRONIZE, 213 HANDLE process = OpenProcess(SYNCHRONIZE,
212 FALSE, 214 FALSE,
213 entry->th32ProcessID); 215 entry->th32ProcessID);
214 DWORD wait_result = WaitForSingleObject(process, remaining_wait); 216 DWORD wait_result = WaitForSingleObject(process, remaining_wait);
215 CloseHandle(process); 217 CloseHandle(process);
216 result &= (wait_result == WAIT_OBJECT_0); 218 result &= (wait_result == WAIT_OBJECT_0);
217 } 219 }
218 220
219 return result; 221 return result;
220 } 222 }
(...skipping 23 matching lines...) Expand all
244 } 246 }
245 247
246 MessageLoop::current()->PostDelayedTask( 248 MessageLoop::current()->PostDelayedTask(
247 FROM_HERE, 249 FROM_HERE,
248 base::Bind(&TimerExpiredTask::TimedOut, 250 base::Bind(&TimerExpiredTask::TimedOut,
249 base::Owned(new TimerExpiredTask(process))), 251 base::Owned(new TimerExpiredTask(process))),
250 base::TimeDelta::FromMilliseconds(kWaitInterval)); 252 base::TimeDelta::FromMilliseconds(kWaitInterval));
251 } 253 }
252 254
253 } // namespace base 255 } // namespace base
OLDNEW
« no previous file with comments | « base/numerics/safe_math_impl.h ('k') | base/strings/string_number_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698