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