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

Side by Side Diff: content/browser/child_process_launcher.h

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

Powered by Google App Engine
This is Rietveld 408576698