OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 uint64_t ReadTransferCount; | 78 uint64_t ReadTransferCount; |
79 uint64_t WriteTransferCount; | 79 uint64_t WriteTransferCount; |
80 uint64_t OtherTransferCount; | 80 uint64_t OtherTransferCount; |
81 }; | 81 }; |
82 | 82 |
83 #endif // defined(OS_POSIX) | 83 #endif // defined(OS_POSIX) |
84 | 84 |
85 // A minimalistic but hopefully cross-platform set of exit codes. | 85 // A minimalistic but hopefully cross-platform set of exit codes. |
86 // Do not change the enumeration values or you will break third-party | 86 // Do not change the enumeration values or you will break third-party |
87 // installers. | 87 // installers. |
| 88 // Warning: This enum is duplicated and extended in chrome/common/result_codes.h |
| 89 // The two must be kept in sync and users of that enum would prefer the |
| 90 // numbering didn't change. |
88 enum { | 91 enum { |
89 PROCESS_END_NORMAL_TERMINATION = 0, | 92 PROCESS_END_NORMAL_TERMINATION = 0, |
90 PROCESS_END_KILLED_BY_USER = 1, | 93 PROCESS_END_KILLED_BY_USER = 1, |
91 PROCESS_END_PROCESS_WAS_HUNG = 2 | 94 PROCESS_END_PROCESS_WAS_HUNG = 2 |
92 }; | 95 }; |
93 | 96 |
94 // Returns the id of the current process. | 97 // Returns the id of the current process. |
95 ProcessId GetCurrentProcId(); | 98 ProcessId GetCurrentProcId(); |
96 | 99 |
97 // Returns the ProcessHandle of the current process. | 100 // Returns the ProcessHandle of the current process. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 bool LaunchApp(const CommandLine& cl, | 235 bool LaunchApp(const CommandLine& cl, |
233 bool wait, bool start_hidden, ProcessHandle* process_handle); | 236 bool wait, bool start_hidden, ProcessHandle* process_handle); |
234 | 237 |
235 // Executes the application specified by |cl| and wait for it to exit. Stores | 238 // Executes the application specified by |cl| and wait for it to exit. Stores |
236 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true | 239 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true |
237 // on success (application launched and exited cleanly, with exit code | 240 // on success (application launched and exited cleanly, with exit code |
238 // indicating success). | 241 // indicating success). |
239 bool GetAppOutput(const CommandLine& cl, std::string* output); | 242 bool GetAppOutput(const CommandLine& cl, std::string* output); |
240 | 243 |
241 #if defined(OS_POSIX) | 244 #if defined(OS_POSIX) |
| 245 // Similar to |GetAppOutput()|. Returns true if process launched and |
| 246 // exited cleanly, with exit code indicating success. Waits no more than |
| 247 // |timeout_milliseconds| for the launched process to exit. After timeout |
| 248 // is triggered, the process is killed and true is stored in |timed_out|. |
| 249 // Will wait for process to die so this may overrun |timeout_milliseconds|. |
| 250 // TODO(tessamac): implement this for windows. |
| 251 bool GetAppOutputWithTimeout(const CommandLine& cl, std::string* output, |
| 252 bool* timed_out, int timeout_milliseconds); |
| 253 |
242 // A restricted version of |GetAppOutput()| which (a) clears the environment, | 254 // A restricted version of |GetAppOutput()| which (a) clears the environment, |
243 // and (b) stores at most |max_output| bytes; also, it doesn't search the path | 255 // and (b) stores at most |max_output| bytes; also, it doesn't search the path |
244 // for the command. | 256 // for the command. |
245 bool GetAppOutputRestricted(const CommandLine& cl, | 257 bool GetAppOutputRestricted(const CommandLine& cl, |
246 std::string* output, size_t max_output); | 258 std::string* output, size_t max_output); |
247 #endif | 259 #endif |
248 | 260 |
249 // Used to filter processes by process ID. | 261 // Used to filter processes by process ID. |
250 class ProcessFilter { | 262 class ProcessFilter { |
251 public: | 263 public: |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // instance running inside the parent. The parent's Breakpad instance should | 604 // instance running inside the parent. The parent's Breakpad instance should |
593 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 605 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
594 // in the child after forking will restore the standard exception handler. | 606 // in the child after forking will restore the standard exception handler. |
595 // See http://crbug.com/20371/ for more details. | 607 // See http://crbug.com/20371/ for more details. |
596 void RestoreDefaultExceptionHandler(); | 608 void RestoreDefaultExceptionHandler(); |
597 #endif // defined(OS_MACOSX) | 609 #endif // defined(OS_MACOSX) |
598 | 610 |
599 } // namespace base | 611 } // namespace base |
600 | 612 |
601 #endif // BASE_PROCESS_UTIL_H_ | 613 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |