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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
157 *exit_code = temp_code; | 157 if (exit_code) |
| 158 *exit_code = temp_code; |
158 return true; | 159 return true; |
159 } | 160 } |
160 | 161 |
161 bool Process::IsProcessBackgrounded() const { | 162 bool Process::IsProcessBackgrounded() const { |
162 DCHECK(IsValid()); | 163 DCHECK(IsValid()); |
163 DWORD priority = GetPriority(); | 164 DWORD priority = GetPriority(); |
164 if (priority == 0) | 165 if (priority == 0) |
165 return false; // Failure case. | 166 return false; // Failure case. |
166 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) || | 167 return ((priority == BELOW_NORMAL_PRIORITY_CLASS) || |
167 (priority == IDLE_PRIORITY_CLASS)); | 168 (priority == IDLE_PRIORITY_CLASS)); |
(...skipping 28 matching lines...) Expand all Loading... |
196 | 197 |
197 return (::SetPriorityClass(Handle(), priority) != 0); | 198 return (::SetPriorityClass(Handle(), priority) != 0); |
198 } | 199 } |
199 | 200 |
200 int Process::GetPriority() const { | 201 int Process::GetPriority() const { |
201 DCHECK(IsValid()); | 202 DCHECK(IsValid()); |
202 return ::GetPriorityClass(Handle()); | 203 return ::GetPriorityClass(Handle()); |
203 } | 204 } |
204 | 205 |
205 } // namespace base | 206 } // namespace base |
OLD | NEW |