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

Side by Side Diff: base/mp/mp_child_process_launcher.h

Issue 1625015: Refactor ChildProcess and related classes to create a framework outside of br... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 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/mp/mp_child_process_host.cc ('k') | base/mp/mp_child_process_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_MP_CHILD_PROCESS_LAUNCHER_H_
6 #define BASE_MP_CHILD_PROCESS_LAUNCHER_H_
7
8 #include "base/basictypes.h"
9 #include "base/mp/mp_child_process_context.h"
10 #include "base/process_util.h"
11 #include "base/ref_counted.h"
12
13 class CommandLine;
14 class MessageLoop;
15
16 namespace base {
17
18 // Launches a process asynchronously and notifies the client of the process
19 // handle when it's available. It's used to avoid blocking the calling thread
20 // on the OS since often it can take > 100 ms to create the process.
21 class MpChildProcessLauncher {
22 public:
23 class Client {
24 public:
25 // Will be called on the thread that the MpChildProcessLauncher was
26 // constructed on.
27 virtual void OnProcessLaunched() = 0;
28 };
29
30 // Launches the process asynchronously, calling the client when the result is
31 // ready. Deleting this object before the process is created is safe, since
32 // the callback won't be called. If the process is still running by the time
33 // this object destructs, it will be terminated.
34 // Takes ownership of cmd_line.
35 MpChildProcessLauncher(
36 #if defined(OS_WIN)
37 const FilePath& exposed_dir,
38 #elif defined(OS_POSIX)
39 bool use_zygote,
40 const base::environment_vector& environ,
41 int ipcfd,
42 #endif
43 CommandLine* cmd_line,
44 MpChildProcessContext* context,
45 Client* client);
46 virtual ~MpChildProcessLauncher();
47
48 // True if the process is being launched and so the handle isn't available.
49 bool IsStarting();
50
51 // Getter for the process handle. Only call after the process has started.
52 base::ProcessHandle GetHandle();
53
54 // Call this when the process exits to know if a process crashed or not.
55 bool DidProcessCrash();
56
57 // Changes whether the process runs in the background or not. Only call
58 // this after the process has started.
59 void SetProcessBackgrounded(bool background);
60
61 private:
62 class Context;
63
64 scoped_refptr<Context> context_;
65 MpChildProcessContext* process_context_;
66
67 DISALLOW_COPY_AND_ASSIGN(MpChildProcessLauncher);
68 };
69
70 } // namespace base
71
72 #endif // BASE_MP_CHILD_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « base/mp/mp_child_process_host.cc ('k') | base/mp/mp_child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698