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

Side by Side Diff: base/process_util.h

Issue 13845008: [Mac] Remove base::LaunchSynchronize and rewrite content::MachBroker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix link_settings Created 7 years, 8 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 | « base/mac/scoped_mach_port.cc ('k') | 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 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 // Close all file descriptors, except those which are a destination in the 226 // Close all file descriptors, except those which are a destination in the
227 // given multimap. Only call this function in a child process where you know 227 // given multimap. Only call this function in a child process where you know
228 // that there aren't any other threads. 228 // that there aren't any other threads.
229 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map); 229 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map);
230 #endif // defined(OS_POSIX) 230 #endif // defined(OS_POSIX)
231 231
232 typedef std::vector<std::pair<std::string, std::string> > EnvironmentVector; 232 typedef std::vector<std::pair<std::string, std::string> > EnvironmentVector;
233 typedef std::vector<std::pair<int, int> > FileHandleMappingVector; 233 typedef std::vector<std::pair<int, int> > FileHandleMappingVector;
234 234
235 #if defined(OS_MACOSX)
236 // Used with LaunchOptions::synchronize and LaunchSynchronize, a
237 // LaunchSynchronizationHandle is an opaque value that LaunchProcess will
238 // create and set, and that LaunchSynchronize will consume and destroy.
239 typedef int* LaunchSynchronizationHandle;
240 #endif // defined(OS_MACOSX)
241
242 // Options for launching a subprocess that are passed to LaunchProcess(). 235 // Options for launching a subprocess that are passed to LaunchProcess().
243 // The default constructor constructs the object with default options. 236 // The default constructor constructs the object with default options.
244 struct LaunchOptions { 237 struct LaunchOptions {
245 LaunchOptions() 238 LaunchOptions()
246 : wait(false), 239 : wait(false),
247 debug(false), 240 debug(false),
248 #if defined(OS_WIN) 241 #if defined(OS_WIN)
249 start_hidden(false), 242 start_hidden(false),
250 inherit_handles(false), 243 inherit_handles(false),
251 as_user(NULL), 244 as_user(NULL),
252 empty_desktop_name(false), 245 empty_desktop_name(false),
253 job_handle(NULL), 246 job_handle(NULL),
254 stdin_handle(NULL), 247 stdin_handle(NULL),
255 stdout_handle(NULL), 248 stdout_handle(NULL),
256 stderr_handle(NULL), 249 stderr_handle(NULL),
257 force_breakaway_from_job_(false) 250 force_breakaway_from_job_(false)
258 #else 251 #else
259 environ(NULL), 252 environ(NULL),
260 fds_to_remap(NULL), 253 fds_to_remap(NULL),
261 maximize_rlimits(NULL), 254 maximize_rlimits(NULL),
262 new_process_group(false) 255 new_process_group(false)
263 #if defined(OS_LINUX) 256 #if defined(OS_LINUX)
264 , clone_flags(0) 257 , clone_flags(0)
265 #endif // OS_LINUX 258 #endif // OS_LINUX
266 #if defined(OS_CHROMEOS) 259 #if defined(OS_CHROMEOS)
267 , ctrl_terminal_fd(-1) 260 , ctrl_terminal_fd(-1)
268 #endif // OS_CHROMEOS 261 #endif // OS_CHROMEOS
269 #if defined(OS_MACOSX)
270 , synchronize(NULL)
271 #endif // defined(OS_MACOSX)
272 #endif // !defined(OS_WIN) 262 #endif // !defined(OS_WIN)
273 {} 263 {}
274 264
275 // If true, wait for the process to complete. 265 // If true, wait for the process to complete.
276 bool wait; 266 bool wait;
277 267
278 // If true, print more debugging info (OS-dependent). 268 // If true, print more debugging info (OS-dependent).
279 bool debug; 269 bool debug;
280 270
281 #if defined(OS_WIN) 271 #if defined(OS_WIN)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // If non-zero, start the process using clone(), using flags as provided. 333 // If non-zero, start the process using clone(), using flags as provided.
344 int clone_flags; 334 int clone_flags;
345 #endif // defined(OS_LINUX) 335 #endif // defined(OS_LINUX)
346 336
347 #if defined(OS_CHROMEOS) 337 #if defined(OS_CHROMEOS)
348 // If non-negative, the specified file descriptor will be set as the launched 338 // If non-negative, the specified file descriptor will be set as the launched
349 // process' controlling terminal. 339 // process' controlling terminal.
350 int ctrl_terminal_fd; 340 int ctrl_terminal_fd;
351 #endif // defined(OS_CHROMEOS) 341 #endif // defined(OS_CHROMEOS)
352 342
353 #if defined(OS_MACOSX)
354 // When non-NULL, a new LaunchSynchronizationHandle will be created and
355 // stored in *synchronize whenever LaunchProcess returns true in the parent
356 // process. The child process will have been created (with fork) but will
357 // be waiting (before exec) for the parent to call LaunchSynchronize with
358 // this handle. Only when LaunchSynchronize is called will the child be
359 // permitted to continue execution and call exec. LaunchSynchronize
360 // destroys the handle created by LaunchProcess.
361 //
362 // When synchronize is non-NULL, the parent must call LaunchSynchronize
363 // whenever LaunchProcess returns true. No exceptions.
364 //
365 // Synchronization is useful when the parent process needs to guarantee that
366 // it can take some action (such as recording the newly-forked child's
367 // process ID) before the child does something (such as using its process ID
368 // to communicate with its parent).
369 //
370 // |synchronize| and |wait| must not both be set simultaneously.
371 LaunchSynchronizationHandle* synchronize;
372 #endif // defined(OS_MACOSX)
373
374 #endif // !defined(OS_WIN) 343 #endif // !defined(OS_WIN)
375 }; 344 };
376 345
377 // Launch a process via the command line |cmdline|. 346 // Launch a process via the command line |cmdline|.
378 // See the documentation of LaunchOptions for details on |options|. 347 // See the documentation of LaunchOptions for details on |options|.
379 // 348 //
380 // Returns true upon success. 349 // Returns true upon success.
381 // 350 //
382 // Upon success, if |process_handle| is non-NULL, it will be filled in with the 351 // Upon success, if |process_handle| is non-NULL, it will be filled in with the
383 // handle of the launched process. NOTE: In this case, the caller is 352 // handle of the launched process. NOTE: In this case, the caller is
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 404
436 // AlterEnvironment returns a modified environment vector, constructed from the 405 // AlterEnvironment returns a modified environment vector, constructed from the
437 // given environment and the list of changes given in |changes|. Each key in 406 // given environment and the list of changes given in |changes|. Each key in
438 // the environment is matched against the first element of the pairs. In the 407 // the environment is matched against the first element of the pairs. In the
439 // event of a match, the value is replaced by the second of the pair, unless 408 // event of a match, the value is replaced by the second of the pair, unless
440 // the second is empty, in which case the key-value is removed. 409 // the second is empty, in which case the key-value is removed.
441 // 410 //
442 // The returned array is allocated using new[] and must be freed by the caller. 411 // The returned array is allocated using new[] and must be freed by the caller.
443 BASE_EXPORT char** AlterEnvironment(const EnvironmentVector& changes, 412 BASE_EXPORT char** AlterEnvironment(const EnvironmentVector& changes,
444 const char* const* const env); 413 const char* const* const env);
445
446 #if defined(OS_MACOSX)
447
448 // After a successful call to LaunchProcess with LaunchOptions::synchronize
449 // set, the parent process must call LaunchSynchronize to allow the child
450 // process to proceed, and to destroy the LaunchSynchronizationHandle.
451 BASE_EXPORT void LaunchSynchronize(LaunchSynchronizationHandle handle);
452
453 #endif // defined(OS_MACOSX)
454 #endif // defined(OS_POSIX) 414 #endif // defined(OS_POSIX)
455 415
456 #if defined(OS_WIN) 416 #if defined(OS_WIN)
457 // Set JOBOBJECT_EXTENDED_LIMIT_INFORMATION to JobObject |job_object|. 417 // Set JOBOBJECT_EXTENDED_LIMIT_INFORMATION to JobObject |job_object|.
458 // As its limit_info.BasicLimitInformation.LimitFlags has 418 // As its limit_info.BasicLimitInformation.LimitFlags has
459 // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. 419 // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE.
460 // When the provide JobObject |job_object| is closed, the binded process will 420 // When the provide JobObject |job_object| is closed, the binded process will
461 // be terminated. 421 // be terminated.
462 BASE_EXPORT bool SetJobObjectAsKillOnJobClose(HANDLE job_object); 422 BASE_EXPORT bool SetJobObjectAsKillOnJobClose(HANDLE job_object);
463 #endif // defined(OS_WIN) 423 #endif // defined(OS_WIN)
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. 873 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU.
914 // 874 //
915 // TODO(shess): Weird place to put it, but this is where the OOM 875 // TODO(shess): Weird place to put it, but this is where the OOM
916 // killer currently lives. 876 // killer currently lives.
917 BASE_EXPORT void* UncheckedMalloc(size_t size); 877 BASE_EXPORT void* UncheckedMalloc(size_t size);
918 #endif // defined(OS_MACOSX) 878 #endif // defined(OS_MACOSX)
919 879
920 } // namespace base 880 } // namespace base
921 881
922 #endif // BASE_PROCESS_UTIL_H_ 882 #endif // BASE_PROCESS_UTIL_H_
OLDNEW
« no previous file with comments | « base/mac/scoped_mach_port.cc ('k') | base/process_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698