OLD | NEW |
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 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 | 12 |
13 class CommandLine; | 13 class CommandLine; |
14 | 14 |
15 namespace content { | 15 namespace content { |
| 16 class SandboxedProcessLauncherDelegate; |
16 | 17 |
17 // Launches a process asynchronously and notifies the client of the process | 18 // Launches a process asynchronously and notifies the client of the process |
18 // handle when it's available. It's used to avoid blocking the calling thread | 19 // handle when it's available. It's used to avoid blocking the calling thread |
19 // on the OS since often it can take > 100 ms to create the process. | 20 // on the OS since often it can take > 100 ms to create the process. |
20 class CONTENT_EXPORT ChildProcessLauncher { | 21 class CONTENT_EXPORT ChildProcessLauncher { |
21 public: | 22 public: |
22 class CONTENT_EXPORT Client { | 23 class CONTENT_EXPORT Client { |
23 public: | 24 public: |
24 // Will be called on the thread that the ChildProcessLauncher was | 25 // Will be called on the thread that the ChildProcessLauncher was |
25 // constructed on. | 26 // constructed on. |
26 virtual void OnProcessLaunched() = 0; | 27 virtual void OnProcessLaunched() = 0; |
27 | 28 |
28 protected: | 29 protected: |
29 virtual ~Client() {} | 30 virtual ~Client() {} |
30 }; | 31 }; |
31 | 32 |
32 // Launches the process asynchronously, calling the client when the result is | 33 // Launches the process asynchronously, calling the client when the result is |
33 // ready. Deleting this object before the process is created is safe, since | 34 // ready. Deleting this object before the process is created is safe, since |
34 // the callback won't be called. If the process is still running by the time | 35 // the callback won't be called. If the process is still running by the time |
35 // this object destructs, it will be terminated. | 36 // this object destructs, it will be terminated. |
36 // Takes ownership of cmd_line. | 37 // Takes ownership of cmd_line. |
37 ChildProcessLauncher( | 38 ChildProcessLauncher( |
38 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
39 const base::FilePath& exposed_dir, | 40 SandboxedProcessLauncherDelegate* delegate, |
40 #elif defined(OS_POSIX) | 41 #elif defined(OS_POSIX) |
41 bool use_zygote, | 42 bool use_zygote, |
42 const base::EnvironmentVector& environ, | 43 const base::EnvironmentVector& environ, |
43 int ipcfd, | 44 int ipcfd, |
44 #endif | 45 #endif |
45 CommandLine* cmd_line, | 46 CommandLine* cmd_line, |
46 int child_process_id, | 47 int child_process_id, |
47 Client* client); | 48 Client* client); |
48 ~ChildProcessLauncher(); | 49 ~ChildProcessLauncher(); |
49 | 50 |
(...skipping 24 matching lines...) Expand all Loading... |
74 class Context; | 75 class Context; |
75 | 76 |
76 scoped_refptr<Context> context_; | 77 scoped_refptr<Context> context_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 79 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
79 }; | 80 }; |
80 | 81 |
81 } // namespace content | 82 } // namespace content |
82 | 83 |
83 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 84 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
OLD | NEW |