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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 612 } |
613 | 613 |
614 bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) { | 614 bool WaitForSingleProcess(ProcessHandle handle, base::TimeDelta wait) { |
615 int exit_code; | 615 int exit_code; |
616 if (!WaitForExitCodeWithTimeout(handle, &exit_code, wait)) | 616 if (!WaitForExitCodeWithTimeout(handle, &exit_code, wait)) |
617 return false; | 617 return false; |
618 return exit_code == 0; | 618 return exit_code == 0; |
619 } | 619 } |
620 | 620 |
621 bool CleanupProcesses(const FilePath::StringType& executable_name, | 621 bool CleanupProcesses(const FilePath::StringType& executable_name, |
622 int64 wait_milliseconds, | 622 base::TimeDelta wait, |
623 int exit_code, | 623 int exit_code, |
624 const ProcessFilter* filter) { | 624 const ProcessFilter* filter) { |
625 bool exited_cleanly = WaitForProcessesToExit( | 625 bool exited_cleanly = WaitForProcessesToExit(executable_name, wait, filter); |
626 executable_name, | |
627 base::TimeDelta::FromMilliseconds(wait_milliseconds), | |
628 filter); | |
629 if (!exited_cleanly) | 626 if (!exited_cleanly) |
630 KillProcesses(executable_name, exit_code, filter); | 627 KillProcesses(executable_name, exit_code, filter); |
631 return exited_cleanly; | 628 return exited_cleanly; |
632 } | 629 } |
633 | 630 |
634 void EnsureProcessTerminated(ProcessHandle process) { | 631 void EnsureProcessTerminated(ProcessHandle process) { |
635 DCHECK(process != GetCurrentProcess()); | 632 DCHECK(process != GetCurrentProcess()); |
636 | 633 |
637 // If already signaled, then we are done! | 634 // If already signaled, then we are done! |
638 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { | 635 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 | 995 |
999 PERFORMANCE_INFORMATION info; | 996 PERFORMANCE_INFORMATION info; |
1000 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 997 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
1001 DLOG(ERROR) << "Failed to fetch internal performance info."; | 998 DLOG(ERROR) << "Failed to fetch internal performance info."; |
1002 return 0; | 999 return 0; |
1003 } | 1000 } |
1004 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 1001 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
1005 } | 1002 } |
1006 | 1003 |
1007 } // namespace base | 1004 } // namespace base |
OLD | NEW |