Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: base/process_util.h

Issue 3012004: Revert 52608 - Add and alternative GetAppOutput() to process_util that takes ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/process_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
91 enum { 88 enum {
92 PROCESS_END_NORMAL_TERMINATION = 0, 89 PROCESS_END_NORMAL_TERMINATION = 0,
93 PROCESS_END_KILLED_BY_USER = 1, 90 PROCESS_END_KILLED_BY_USER = 1,
94 PROCESS_END_PROCESS_WAS_HUNG = 2 91 PROCESS_END_PROCESS_WAS_HUNG = 2
95 }; 92 };
96 93
97 // Returns the id of the current process. 94 // Returns the id of the current process.
98 ProcessId GetCurrentProcId(); 95 ProcessId GetCurrentProcId();
99 96
100 // Returns the ProcessHandle of the current process. 97 // Returns the ProcessHandle of the current process.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 bool LaunchApp(const CommandLine& cl, 232 bool LaunchApp(const CommandLine& cl,
236 bool wait, bool start_hidden, ProcessHandle* process_handle); 233 bool wait, bool start_hidden, ProcessHandle* process_handle);
237 234
238 // Executes the application specified by |cl| and wait for it to exit. Stores 235 // Executes the application specified by |cl| and wait for it to exit. Stores
239 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true 236 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true
240 // on success (application launched and exited cleanly, with exit code 237 // on success (application launched and exited cleanly, with exit code
241 // indicating success). 238 // indicating success).
242 bool GetAppOutput(const CommandLine& cl, std::string* output); 239 bool GetAppOutput(const CommandLine& cl, std::string* output);
243 240
244 #if defined(OS_POSIX) 241 #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
254 // A restricted version of |GetAppOutput()| which (a) clears the environment, 242 // A restricted version of |GetAppOutput()| which (a) clears the environment,
255 // and (b) stores at most |max_output| bytes; also, it doesn't search the path 243 // and (b) stores at most |max_output| bytes; also, it doesn't search the path
256 // for the command. 244 // for the command.
257 bool GetAppOutputRestricted(const CommandLine& cl, 245 bool GetAppOutputRestricted(const CommandLine& cl,
258 std::string* output, size_t max_output); 246 std::string* output, size_t max_output);
259 #endif 247 #endif
260 248
261 // Used to filter processes by process ID. 249 // Used to filter processes by process ID.
262 class ProcessFilter { 250 class ProcessFilter {
263 public: 251 public:
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // instance running inside the parent. The parent's Breakpad instance should 592 // instance running inside the parent. The parent's Breakpad instance should
605 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler 593 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler
606 // in the child after forking will restore the standard exception handler. 594 // in the child after forking will restore the standard exception handler.
607 // See http://crbug.com/20371/ for more details. 595 // See http://crbug.com/20371/ for more details.
608 void RestoreDefaultExceptionHandler(); 596 void RestoreDefaultExceptionHandler();
609 #endif // defined(OS_MACOSX) 597 #endif // defined(OS_MACOSX)
610 598
611 } // namespace base 599 } // namespace base
612 600
613 #endif // BASE_PROCESS_UTIL_H_ 601 #endif // BASE_PROCESS_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/process_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698