OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // signaled then puts the exit code in |exit_code|; otherwise it's considered | 200 // signaled then puts the exit code in |exit_code|; otherwise it's considered |
201 // a failure. On Windows |exit_code| is always filled. Returns true on success, | 201 // a failure. On Windows |exit_code| is always filled. Returns true on success, |
202 // and closes |handle| in any case. | 202 // and closes |handle| in any case. |
203 bool WaitForExitCode(ProcessHandle handle, int* exit_code); | 203 bool WaitForExitCode(ProcessHandle handle, int* exit_code); |
204 | 204 |
205 // Wait for all the processes based on the named executable to exit. If filter | 205 // Wait for all the processes based on the named executable to exit. If filter |
206 // is non-null, then only processes selected by the filter are waited on. | 206 // is non-null, then only processes selected by the filter are waited on. |
207 // Returns after all processes have exited or wait_milliseconds have expired. | 207 // Returns after all processes have exited or wait_milliseconds have expired. |
208 // Returns true if all the processes exited, false otherwise. | 208 // Returns true if all the processes exited, false otherwise. |
209 bool WaitForProcessesToExit(const std::wstring& executable_name, | 209 bool WaitForProcessesToExit(const std::wstring& executable_name, |
210 int wait_milliseconds, | 210 int64 wait_milliseconds, |
211 const ProcessFilter* filter); | 211 const ProcessFilter* filter); |
212 | 212 |
213 // Wait for a single process to exit. Return true if it exited cleanly within | 213 // Wait for a single process to exit. Return true if it exited cleanly within |
214 // the given time limit. | 214 // the given time limit. |
215 bool WaitForSingleProcess(ProcessHandle handle, | 215 bool WaitForSingleProcess(ProcessHandle handle, |
216 int wait_milliseconds); | 216 int64 wait_milliseconds); |
217 | 217 |
218 // Returns true when |wait_milliseconds| have elapsed and the process | 218 // Returns true when |wait_milliseconds| have elapsed and the process |
219 // is still running. | 219 // is still running. |
220 bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds); | 220 bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds); |
221 | 221 |
222 // Waits a certain amount of time (can be 0) for all the processes with a given | 222 // Waits a certain amount of time (can be 0) for all the processes with a given |
223 // executable name to exit, then kills off any of them that are still around. | 223 // executable name to exit, then kills off any of them that are still around. |
224 // If filter is non-null, then only processes selected by the filter are waited | 224 // If filter is non-null, then only processes selected by the filter are waited |
225 // on. Killed processes are ended with the given exit code. Returns false if | 225 // on. Killed processes are ended with the given exit code. Returns false if |
226 // any processes needed to be killed, true if they all exited cleanly within | 226 // any processes needed to be killed, true if they all exited cleanly within |
227 // the wait_milliseconds delay. | 227 // the wait_milliseconds delay. |
228 bool CleanupProcesses(const std::wstring& executable_name, | 228 bool CleanupProcesses(const std::wstring& executable_name, |
229 int wait_milliseconds, | 229 int64 wait_milliseconds, |
230 int exit_code, | 230 int exit_code, |
231 const ProcessFilter* filter); | 231 const ProcessFilter* filter); |
232 | 232 |
233 // This class provides a way to iterate through the list of processes | 233 // This class provides a way to iterate through the list of processes |
234 // on the current machine that were started from the given executable | 234 // on the current machine that were started from the given executable |
235 // name. To use, create an instance and then call NextProcessEntry() | 235 // name. To use, create an instance and then call NextProcessEntry() |
236 // until it returns false. | 236 // until it returns false. |
237 class NamedProcessIterator { | 237 class NamedProcessIterator { |
238 public: | 238 public: |
239 NamedProcessIterator(const std::wstring& executable_name, | 239 NamedProcessIterator(const std::wstring& executable_name, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 392 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
393 void EnableTerminationOnHeapCorruption(); | 393 void EnableTerminationOnHeapCorruption(); |
394 | 394 |
395 // If supported on the platform, and the user has sufficent rights, increase | 395 // If supported on the platform, and the user has sufficent rights, increase |
396 // the current process's scheduling priority to a high priority. | 396 // the current process's scheduling priority to a high priority. |
397 void RaiseProcessToHighPriority(); | 397 void RaiseProcessToHighPriority(); |
398 | 398 |
399 } // namespace base | 399 } // namespace base |
400 | 400 |
401 #endif // BASE_PROCESS_UTIL_H_ | 401 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |