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/files/scoped_file.h" | 9 #include "base/files/scoped_file.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/process/kill.h" | 11 #include "base/process/kill.h" |
12 #include "base/process/launch.h" | 12 #include "base/process/launch.h" |
13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class CommandLine; | 20 class CommandLine; |
20 } | 21 } |
21 | 22 |
22 namespace content { | 23 namespace content { |
23 class SandboxedProcessLauncherDelegate; | |
24 | 24 |
25 // Launches a process asynchronously and notifies the client of the process | 25 // Launches a process asynchronously and notifies the client of the process |
26 // handle when it's available. It's used to avoid blocking the calling thread | 26 // handle when it's available. It's used to avoid blocking the calling thread |
27 // on the OS since often it can take > 100 ms to create the process. | 27 // on the OS since often it can take > 100 ms to create the process. |
28 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe { | 28 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe { |
29 public: | 29 public: |
30 class CONTENT_EXPORT Client { | 30 class CONTENT_EXPORT Client { |
31 public: | 31 public: |
32 // Will be called on the thread that the ChildProcessLauncher was | 32 // Will be called on the thread that the ChildProcessLauncher was |
33 // constructed on. | 33 // constructed on. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 int child_process_id); | 87 int child_process_id); |
88 | 88 |
89 void UpdateTerminationStatus(bool known_dead); | 89 void UpdateTerminationStatus(bool known_dead); |
90 | 90 |
91 // This is always called on the client thread after an attempt | 91 // This is always called on the client thread after an attempt |
92 // to launch the child process on the launcher thread. | 92 // to launch the child process on the launcher thread. |
93 // It makes sure we always perform the necessary cleanup if the | 93 // It makes sure we always perform the necessary cleanup if the |
94 // client went away. | 94 // client went away. |
95 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, | 95 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, |
96 bool terminate_on_shutdown, | 96 bool terminate_on_shutdown, |
97 bool zygote, | 97 ZygoteHandle zygote, |
98 #if defined(OS_ANDROID) | 98 #if defined(OS_ANDROID) |
99 base::ScopedFD ipcfd, | 99 base::ScopedFD ipcfd, |
100 #endif | 100 #endif |
101 base::Process process); | 101 base::Process process); |
102 | 102 |
103 // Notifies the client about the result of the operation. | 103 // Notifies the client about the result of the operation. |
104 void Notify(bool zygote, | 104 void Notify(ZygoteHandle zygote, |
105 #if defined(OS_ANDROID) | 105 #if defined(OS_ANDROID) |
106 base::ScopedFD ipcfd, | 106 base::ScopedFD ipcfd, |
107 #endif | 107 #endif |
108 base::Process process); | 108 base::Process process); |
109 | 109 |
110 #if defined(MOJO_SHELL_CLIENT) | 110 #if defined(MOJO_SHELL_CLIENT) |
111 // When this process is run from an external Mojo shell, this function will | 111 // When this process is run from an external Mojo shell, this function will |
112 // create a channel and pass one end to the spawned process and register the | 112 // create a channel and pass one end to the spawned process and register the |
113 // other end with the external shell, allowing the spawned process to bind an | 113 // other end with the external shell, allowing the spawned process to bind an |
114 // Application request from the shell. | 114 // Application request from the shell. |
115 void CreateMojoShellChannel(base::CommandLine* command_line, | 115 void CreateMojoShellChannel(base::CommandLine* command_line, |
116 int child_process_id); | 116 int child_process_id); |
117 #endif | 117 #endif |
118 | 118 |
119 Client* client_; | 119 Client* client_; |
120 BrowserThread::ID client_thread_id_; | 120 BrowserThread::ID client_thread_id_; |
121 base::Process process_; | 121 base::Process process_; |
122 base::TerminationStatus termination_status_; | 122 base::TerminationStatus termination_status_; |
123 int exit_code_; | 123 int exit_code_; |
124 bool zygote_; | 124 ZygoteHandle zygote_; |
125 bool starting_; | 125 bool starting_; |
126 // Controls whether the child process should be terminated on browser | 126 // Controls whether the child process should be terminated on browser |
127 // shutdown. Default behavior is to terminate the child. | 127 // shutdown. Default behavior is to terminate the child. |
128 const bool terminate_child_on_shutdown_; | 128 const bool terminate_child_on_shutdown_; |
129 | 129 |
130 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; | 130 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 132 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
133 }; | 133 }; |
134 | 134 |
135 } // namespace content | 135 } // namespace content |
136 | 136 |
137 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 137 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
OLD | NEW |