| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 147 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 148 // Limit timeout to INFINITE. | 148 // Limit timeout to INFINITE. |
| 149 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds()); | 149 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds()); |
| 150 if (::WaitForSingleObject(Handle(), timeout_ms) != WAIT_OBJECT_0) | 150 if (::WaitForSingleObject(Handle(), timeout_ms) != WAIT_OBJECT_0) |
| 151 return false; | 151 return false; |
| 152 | 152 |
| 153 DWORD temp_code; // Don't clobber out-parameters in case of failure. | 153 DWORD temp_code; // Don't clobber out-parameters in case of failure. |
| 154 if (!::GetExitCodeProcess(Handle(), &temp_code)) | 154 if (!::GetExitCodeProcess(Handle(), &temp_code)) |
| 155 return false; | 155 return false; |
| 156 | 156 if (exit_code) |
| 157 *exit_code = temp_code; | 157 *exit_code = temp_code; |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool Process::IsProcessBackgrounded() const { | 161 bool Process::IsProcessBackgrounded() const { |
| 162 DCHECK(IsValid()); | 162 DCHECK(IsValid()); |
| 163 DWORD priority = GetPriority(); | 163 DWORD priority = GetPriority(); |
| 164 if (priority == 0) | 164 if (priority == 0) |
| 165 return false; // Failure case. | 165 return false; // Failure case. |
| 166 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) || | 166 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) || |
| 167 (priority == IDLE_PRIORITY_CLASS)); | 167 (priority == IDLE_PRIORITY_CLASS)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 196 | 196 |
| 197 return (::SetPriorityClass(Handle(), priority) != 0); | 197 return (::SetPriorityClass(Handle(), priority) != 0); |
| 198 } | 198 } |
| 199 | 199 |
| 200 int Process::GetPriority() const { | 200 int Process::GetPriority() const { |
| 201 DCHECK(IsValid()); | 201 DCHECK(IsValid()); |
| 202 return ::GetPriorityClass(Handle()); | 202 return ::GetPriorityClass(Handle()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace base | 205 } // namespace base |
| OLD | NEW |