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. | |
92 enum { | 89 enum { |
93 PROCESS_END_NORMAL_TERMINATION = 0, | 90 PROCESS_END_NORMAL_TERMINATION = 0, |
94 PROCESS_END_KILLED_BY_USER = 1, | 91 PROCESS_END_KILLED_BY_USER = 1, |
95 PROCESS_END_PROCESS_WAS_HUNG = 2 | 92 PROCESS_END_PROCESS_WAS_HUNG = 2 |
96 }; | 93 }; |
97 | 94 |
98 // Returns the id of the current process. | 95 // Returns the id of the current process. |
99 ProcessId GetCurrentProcId(); | 96 ProcessId GetCurrentProcId(); |
100 | 97 |
101 // Returns the ProcessHandle of the current process. | 98 // Returns the ProcessHandle of the current process. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 bool LaunchApp(const CommandLine& cl, | 233 bool LaunchApp(const CommandLine& cl, |
237 bool wait, bool start_hidden, ProcessHandle* process_handle); | 234 bool wait, bool start_hidden, ProcessHandle* process_handle); |
238 | 235 |
239 // Executes the application specified by |cl| and wait for it to exit. Stores | 236 // Executes the application specified by |cl| and wait for it to exit. Stores |
240 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true | 237 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true |
241 // on success (application launched and exited cleanly, with exit code | 238 // on success (application launched and exited cleanly, with exit code |
242 // indicating success). | 239 // indicating success). |
243 bool GetAppOutput(const CommandLine& cl, std::string* output); | 240 bool GetAppOutput(const CommandLine& cl, std::string* output); |
244 | 241 |
245 #if defined(OS_POSIX) | 242 #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 | |
255 // A restricted version of |GetAppOutput()| which (a) clears the environment, | 243 // A restricted version of |GetAppOutput()| which (a) clears the environment, |
256 // and (b) stores at most |max_output| bytes; also, it doesn't search the path | 244 // and (b) stores at most |max_output| bytes; also, it doesn't search the path |
257 // for the command. | 245 // for the command. |
258 bool GetAppOutputRestricted(const CommandLine& cl, | 246 bool GetAppOutputRestricted(const CommandLine& cl, |
259 std::string* output, size_t max_output); | 247 std::string* output, size_t max_output); |
260 #endif | 248 #endif |
261 | 249 |
262 // Used to filter processes by process ID. | 250 // Used to filter processes by process ID. |
263 class ProcessFilter { | 251 class ProcessFilter { |
264 public: | 252 public: |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // instance running inside the parent. The parent's Breakpad instance should | 593 // instance running inside the parent. The parent's Breakpad instance should |
606 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 594 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
607 // in the child after forking will restore the standard exception handler. | 595 // in the child after forking will restore the standard exception handler. |
608 // See http://crbug.com/20371/ for more details. | 596 // See http://crbug.com/20371/ for more details. |
609 void RestoreDefaultExceptionHandler(); | 597 void RestoreDefaultExceptionHandler(); |
610 #endif // defined(OS_MACOSX) | 598 #endif // defined(OS_MACOSX) |
611 | 599 |
612 } // namespace base | 600 } // namespace base |
613 | 601 |
614 #endif // BASE_PROCESS_UTIL_H_ | 602 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |