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