OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <userenv.h> | 10 #include <userenv.h> |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 case kDebuggerTerminatedExitCode: // Debugger terminated process. | 532 case kDebuggerTerminatedExitCode: // Debugger terminated process. |
533 case kProcessKilledExitCode: // Task manager kill. | 533 case kProcessKilledExitCode: // Task manager kill. |
534 return TERMINATION_STATUS_PROCESS_WAS_KILLED; | 534 return TERMINATION_STATUS_PROCESS_WAS_KILLED; |
535 default: | 535 default: |
536 // All other exit codes indicate crashes. | 536 // All other exit codes indicate crashes. |
537 return TERMINATION_STATUS_PROCESS_CRASHED; | 537 return TERMINATION_STATUS_PROCESS_CRASHED; |
538 } | 538 } |
539 } | 539 } |
540 | 540 |
541 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { | 541 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { |
542 bool success = WaitForExitCodeWithTimeout(handle, exit_code, INFINITE); | 542 bool success = WaitForExitCodeWithTimeout( |
| 543 handle, exit_code, base::TimeDelta::FromMilliseconds(INFINITE)); |
543 CloseProcessHandle(handle); | 544 CloseProcessHandle(handle); |
544 return success; | 545 return success; |
545 } | 546 } |
546 | 547 |
547 bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, | 548 bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, |
548 int64 timeout_milliseconds) { | 549 int64 timeout_milliseconds) { |
549 if (::WaitForSingleObject(handle, timeout_milliseconds) != WAIT_OBJECT_0) | 550 if (::WaitForSingleObject(handle, timeout_milliseconds) != WAIT_OBJECT_0) |
550 return false; | 551 return false; |
551 DWORD temp_code; // Don't clobber out-parameters in case of failure. | 552 DWORD temp_code; // Don't clobber out-parameters in case of failure. |
552 if (!::GetExitCodeProcess(handle, &temp_code)) | 553 if (!::GetExitCodeProcess(handle, &temp_code)) |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1014 |
1014 PERFORMANCE_INFORMATION info; | 1015 PERFORMANCE_INFORMATION info; |
1015 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 1016 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
1016 DLOG(ERROR) << "Failed to fetch internal performance info."; | 1017 DLOG(ERROR) << "Failed to fetch internal performance info."; |
1017 return 0; | 1018 return 0; |
1018 } | 1019 } |
1019 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 1020 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
1020 } | 1021 } |
1021 | 1022 |
1022 } // namespace base | 1023 } // namespace base |
OLD | NEW |