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

Side by Side Diff: base/process_util.h

Issue 9429039: Cleanup: Remove base::environment_vector and base::file_handle_mapping_vector to StudlyCaps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 #if defined(OS_POSIX) 199 #if defined(OS_POSIX)
200 // Returns the ID for the parent of the given process. 200 // Returns the ID for the parent of the given process.
201 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); 201 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process);
202 202
203 // Close all file descriptors, except those which are a destination in the 203 // Close all file descriptors, except those which are a destination in the
204 // given multimap. Only call this function in a child process where you know 204 // given multimap. Only call this function in a child process where you know
205 // that there aren't any other threads. 205 // that there aren't any other threads.
206 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map); 206 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map);
207 #endif // defined(OS_POSIX) 207 #endif // defined(OS_POSIX)
208 208
209 // TODO(evan): rename these to use StudlyCaps. 209 typedef std::vector<std::pair<std::string, std::string> > EnvironmentVector;
210 typedef std::vector<std::pair<std::string, std::string> > environment_vector; 210 typedef std::vector<std::pair<int, int> > FileHandleMappingVector;
211 typedef std::vector<std::pair<int, int> > file_handle_mapping_vector;
212 211
213 #if defined(OS_MACOSX) 212 #if defined(OS_MACOSX)
214 // Used with LaunchOptions::synchronize and LaunchSynchronize, a 213 // Used with LaunchOptions::synchronize and LaunchSynchronize, a
215 // LaunchSynchronizationHandle is an opaque value that LaunchProcess will 214 // LaunchSynchronizationHandle is an opaque value that LaunchProcess will
216 // create and set, and that LaunchSynchronize will consume and destroy. 215 // create and set, and that LaunchSynchronize will consume and destroy.
217 typedef int* LaunchSynchronizationHandle; 216 typedef int* LaunchSynchronizationHandle;
218 #endif // defined(OS_MACOSX) 217 #endif // defined(OS_MACOSX)
219 218
220 // Options for launching a subprocess that are passed to LaunchProcess(). 219 // Options for launching a subprocess that are passed to LaunchProcess().
221 // The default constructor constructs the object with default options. 220 // The default constructor constructs the object with default options.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // If true, use an empty string for the desktop name. 259 // If true, use an empty string for the desktop name.
261 bool empty_desktop_name; 260 bool empty_desktop_name;
262 261
263 // If non-NULL, launches the application in that job object. 262 // If non-NULL, launches the application in that job object.
264 HANDLE job_handle; 263 HANDLE job_handle;
265 #else 264 #else
266 // If non-NULL, set/unset environment variables. 265 // If non-NULL, set/unset environment variables.
267 // See documentation of AlterEnvironment(). 266 // See documentation of AlterEnvironment().
268 // This pointer is owned by the caller and must live through the 267 // This pointer is owned by the caller and must live through the
269 // call to LaunchProcess(). 268 // call to LaunchProcess().
270 const environment_vector* environ; 269 const EnvironmentVector* environ;
271 270
272 // If non-NULL, remap file descriptors according to the mapping of 271 // If non-NULL, remap file descriptors according to the mapping of
273 // src fd->dest fd to propagate FDs into the child process. 272 // src fd->dest fd to propagate FDs into the child process.
274 // This pointer is owned by the caller and must live through the 273 // This pointer is owned by the caller and must live through the
275 // call to LaunchProcess(). 274 // call to LaunchProcess().
276 const file_handle_mapping_vector* fds_to_remap; 275 const FileHandleMappingVector* fds_to_remap;
277 276
278 // Each element is an RLIMIT_* constant that should be raised to its 277 // Each element is an RLIMIT_* constant that should be raised to its
279 // rlim_max. This pointer is owned by the caller and must live through 278 // rlim_max. This pointer is owned by the caller and must live through
280 // the call to LaunchProcess(). 279 // the call to LaunchProcess().
281 const std::set<int>* maximize_rlimits; 280 const std::set<int>* maximize_rlimits;
282 281
283 // If true, start the process in a new process group, instead of 282 // If true, start the process in a new process group, instead of
284 // inheriting the parent's process group. The pgid of the child process 283 // inheriting the parent's process group. The pgid of the child process
285 // will be the same as its pid. 284 // will be the same as its pid.
286 bool new_process_group; 285 bool new_process_group;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 enum IntegrityLevel { 344 enum IntegrityLevel {
346 INTEGRITY_UNKNOWN, 345 INTEGRITY_UNKNOWN,
347 LOW_INTEGRITY, 346 LOW_INTEGRITY,
348 MEDIUM_INTEGRITY, 347 MEDIUM_INTEGRITY,
349 HIGH_INTEGRITY, 348 HIGH_INTEGRITY,
350 }; 349 };
351 // Determine the integrity level of the specified process. Returns false 350 // Determine the integrity level of the specified process. Returns false
352 // if the system does not support integrity levels (pre-Vista) or in the case 351 // if the system does not support integrity levels (pre-Vista) or in the case
353 // of an underlying system failure. 352 // of an underlying system failure.
354 BASE_EXPORT bool GetProcessIntegrityLevel(ProcessHandle process, 353 BASE_EXPORT bool GetProcessIntegrityLevel(ProcessHandle process,
355 IntegrityLevel *level); 354 IntegrityLevel* level);
356 355
357 // Windows-specific LaunchProcess that takes the command line as a 356 // Windows-specific LaunchProcess that takes the command line as a
358 // string. Useful for situations where you need to control the 357 // string. Useful for situations where you need to control the
359 // command line arguments directly, but prefer the CommandLine version 358 // command line arguments directly, but prefer the CommandLine version
360 // if launching Chrome itself. 359 // if launching Chrome itself.
361 // 360 //
362 // The first command line argument should be the path to the process, 361 // The first command line argument should be the path to the process,
363 // and don't forget to quote it. 362 // and don't forget to quote it.
364 // 363 //
365 // Example (including literal quotes) 364 // Example (including literal quotes)
(...skipping 11 matching lines...) Expand all
377 const LaunchOptions& options, 376 const LaunchOptions& options,
378 ProcessHandle* process_handle); 377 ProcessHandle* process_handle);
379 378
380 // AlterEnvironment returns a modified environment vector, constructed from the 379 // AlterEnvironment returns a modified environment vector, constructed from the
381 // given environment and the list of changes given in |changes|. Each key in 380 // given environment and the list of changes given in |changes|. Each key in
382 // the environment is matched against the first element of the pairs. In the 381 // the environment is matched against the first element of the pairs. In the
383 // event of a match, the value is replaced by the second of the pair, unless 382 // event of a match, the value is replaced by the second of the pair, unless
384 // the second is empty, in which case the key-value is removed. 383 // the second is empty, in which case the key-value is removed.
385 // 384 //
386 // The returned array is allocated using new[] and must be freed by the caller. 385 // The returned array is allocated using new[] and must be freed by the caller.
387 BASE_EXPORT char** AlterEnvironment(const environment_vector& changes, 386 BASE_EXPORT char** AlterEnvironment(const EnvironmentVector& changes,
388 const char* const* const env); 387 const char* const* const env);
389 388
390 #if defined(OS_MACOSX) 389 #if defined(OS_MACOSX)
391 390
392 // After a successful call to LaunchProcess with LaunchOptions::synchronize 391 // After a successful call to LaunchProcess with LaunchOptions::synchronize
393 // set, the parent process must call LaunchSynchronize to allow the child 392 // set, the parent process must call LaunchSynchronize to allow the child
394 // process to proceed, and to destroy the LaunchSynchronizationHandle. 393 // process to proceed, and to destroy the LaunchSynchronizationHandle.
395 BASE_EXPORT void LaunchSynchronize(LaunchSynchronizationHandle handle); 394 BASE_EXPORT void LaunchSynchronize(LaunchSynchronizationHandle handle);
396 395
397 #endif // defined(OS_MACOSX) 396 #endif // defined(OS_MACOSX)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // use with Process32First/Process32Next. 578 // use with Process32First/Process32Next.
580 void InitProcessEntry(ProcessEntry* entry); 579 void InitProcessEntry(ProcessEntry* entry);
581 580
582 #if defined(OS_WIN) 581 #if defined(OS_WIN)
583 HANDLE snapshot_; 582 HANDLE snapshot_;
584 bool started_iteration_; 583 bool started_iteration_;
585 #elif defined(OS_MACOSX) || defined(OS_BSD) 584 #elif defined(OS_MACOSX) || defined(OS_BSD)
586 std::vector<kinfo_proc> kinfo_procs_; 585 std::vector<kinfo_proc> kinfo_procs_;
587 size_t index_of_kinfo_proc_; 586 size_t index_of_kinfo_proc_;
588 #elif defined(OS_POSIX) 587 #elif defined(OS_POSIX)
589 DIR *procfs_dir_; 588 DIR* procfs_dir_;
590 #endif 589 #endif
591 ProcessEntry entry_; 590 ProcessEntry entry_;
592 const ProcessFilter* filter_; 591 const ProcessFilter* filter_;
593 592
594 DISALLOW_COPY_AND_ASSIGN(ProcessIterator); 593 DISALLOW_COPY_AND_ASSIGN(ProcessIterator);
595 }; 594 };
596 595
597 // This class provides a way to iterate through the list of processes 596 // This class provides a way to iterate through the list of processes
598 // on the current machine that were started from the given executable 597 // on the current machine that were started from the given executable
599 // name. To use, create an instance and then call NextProcessEntry() 598 // name. To use, create an instance and then call NextProcessEntry()
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 // instance running inside the parent. The parent's Breakpad instance should 827 // instance running inside the parent. The parent's Breakpad instance should
829 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler 828 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler
830 // in the child after forking will restore the standard exception handler. 829 // in the child after forking will restore the standard exception handler.
831 // See http://crbug.com/20371/ for more details. 830 // See http://crbug.com/20371/ for more details.
832 void RestoreDefaultExceptionHandler(); 831 void RestoreDefaultExceptionHandler();
833 #endif // defined(OS_MACOSX) 832 #endif // defined(OS_MACOSX)
834 833
835 } // namespace base 834 } // namespace base
836 835
837 #endif // BASE_PROCESS_UTIL_H_ 836 #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