| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/process.h" | 5 #include "base/process/process.h" |
| 6 | 6 |
| 7 #include "base/debug/activity_tracker.h" | |
| 8 #include "base/logging.h" | 7 #include "base/logging.h" |
| 9 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
| 11 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| 12 | 11 |
| 13 namespace { | 12 namespace { |
| 14 | 13 |
| 15 DWORD kBasicProcessAccess = | 14 DWORD kBasicProcessAccess = |
| 16 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; | 15 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; |
| 17 | 16 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 135 } |
| 137 return result; | 136 return result; |
| 138 } | 137 } |
| 139 | 138 |
| 140 bool Process::WaitForExit(int* exit_code) { | 139 bool Process::WaitForExit(int* exit_code) { |
| 141 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(INFINITE), | 140 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(INFINITE), |
| 142 exit_code); | 141 exit_code); |
| 143 } | 142 } |
| 144 | 143 |
| 145 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 144 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 146 // Record the event that this thread is blocking upon (for hang diagnosis). | |
| 147 base::debug::ScopedProcessWaitActivity process_activity(this); | |
| 148 | |
| 149 // Limit timeout to INFINITE. | 145 // Limit timeout to INFINITE. |
| 150 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds()); | 146 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds()); |
| 151 if (::WaitForSingleObject(Handle(), timeout_ms) != WAIT_OBJECT_0) | 147 if (::WaitForSingleObject(Handle(), timeout_ms) != WAIT_OBJECT_0) |
| 152 return false; | 148 return false; |
| 153 | 149 |
| 154 DWORD temp_code; // Don't clobber out-parameters in case of failure. | 150 DWORD temp_code; // Don't clobber out-parameters in case of failure. |
| 155 if (!::GetExitCodeProcess(Handle(), &temp_code)) | 151 if (!::GetExitCodeProcess(Handle(), &temp_code)) |
| 156 return false; | 152 return false; |
| 157 | 153 |
| 158 if (exit_code) | 154 if (exit_code) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 184 | 180 |
| 185 return (::SetPriorityClass(Handle(), priority) != 0); | 181 return (::SetPriorityClass(Handle(), priority) != 0); |
| 186 } | 182 } |
| 187 | 183 |
| 188 int Process::GetPriority() const { | 184 int Process::GetPriority() const { |
| 189 DCHECK(IsValid()); | 185 DCHECK(IsValid()); |
| 190 return ::GetPriorityClass(Handle()); | 186 return ::GetPriorityClass(Handle()); |
| 191 } | 187 } |
| 192 | 188 |
| 193 } // namespace base | 189 } // namespace base |
| OLD | NEW |