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 #include "content/browser/child_process_launcher.h" | 5 #include "content/browser/child_process_launcher.h" |
6 | 6 |
7 #include <utility> // For std::pair. | 7 #include <utility> // For std::pair. |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #endif | 67 #endif |
68 } | 68 } |
69 | 69 |
70 void Launch( | 70 void Launch( |
71 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
72 SandboxedProcessLauncherDelegate* delegate, | 72 SandboxedProcessLauncherDelegate* delegate, |
73 #elif defined(OS_ANDROID) | 73 #elif defined(OS_ANDROID) |
74 int ipcfd, | 74 int ipcfd, |
75 #elif defined(OS_POSIX) | 75 #elif defined(OS_POSIX) |
76 bool use_zygote, | 76 bool use_zygote, |
77 const base::EnvironmentVector& environ, | 77 const base::EnvironmentMap& environ, |
78 int ipcfd, | 78 int ipcfd, |
79 #endif | 79 #endif |
80 CommandLine* cmd_line, | 80 CommandLine* cmd_line, |
81 int child_process_id, | 81 int child_process_id, |
82 Client* client) { | 82 Client* client) { |
83 client_ = client; | 83 client_ = client; |
84 | 84 |
85 CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_)); | 85 CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_)); |
86 | 86 |
87 #if defined(OS_ANDROID) | 87 #if defined(OS_ANDROID) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // |this_object| is NOT thread safe. Only use it to post a task back. | 179 // |this_object| is NOT thread safe. Only use it to post a task back. |
180 scoped_refptr<Context> this_object, | 180 scoped_refptr<Context> this_object, |
181 BrowserThread::ID client_thread_id, | 181 BrowserThread::ID client_thread_id, |
182 int child_process_id, | 182 int child_process_id, |
183 #if defined(OS_WIN) | 183 #if defined(OS_WIN) |
184 SandboxedProcessLauncherDelegate* delegate, | 184 SandboxedProcessLauncherDelegate* delegate, |
185 #elif defined(OS_ANDROID) | 185 #elif defined(OS_ANDROID) |
186 int ipcfd, | 186 int ipcfd, |
187 #elif defined(OS_POSIX) | 187 #elif defined(OS_POSIX) |
188 bool use_zygote, | 188 bool use_zygote, |
189 const base::EnvironmentVector& env, | 189 const base::EnvironmentMap& env, |
190 int ipcfd, | 190 int ipcfd, |
191 #endif | 191 #endif |
192 CommandLine* cmd_line) { | 192 CommandLine* cmd_line) { |
193 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); | 193 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); |
194 base::TimeTicks begin_launch_time = base::TimeTicks::Now(); | 194 base::TimeTicks begin_launch_time = base::TimeTicks::Now(); |
195 | 195 |
196 #if defined(OS_WIN) | 196 #if defined(OS_WIN) |
197 scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate); | 197 scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate); |
198 base::ProcessHandle handle = StartSandboxedProcess(delegate, cmd_line); | 198 base::ProcessHandle handle = StartSandboxedProcess(delegate, cmd_line); |
199 #elif defined(OS_ANDROID) | 199 #elif defined(OS_ANDROID) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const int sandbox_fd = | 255 const int sandbox_fd = |
256 RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 256 RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
257 fds_to_map.push_back(std::make_pair( | 257 fds_to_map.push_back(std::make_pair( |
258 sandbox_fd, | 258 sandbox_fd, |
259 kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); | 259 kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
260 } | 260 } |
261 #endif // defined(OS_MACOSX) | 261 #endif // defined(OS_MACOSX) |
262 | 262 |
263 // Actually launch the app. | 263 // Actually launch the app. |
264 base::LaunchOptions options; | 264 base::LaunchOptions options; |
265 options.environ = &env; | 265 options.environ = env; |
266 options.fds_to_remap = &fds_to_map; | 266 options.fds_to_remap = &fds_to_map; |
267 | 267 |
268 #if defined(OS_MACOSX) | 268 #if defined(OS_MACOSX) |
269 // Hold the MachBroker lock for the duration of LaunchProcess. The child | 269 // Hold the MachBroker lock for the duration of LaunchProcess. The child |
270 // will send its task port to the parent almost immediately after startup. | 270 // will send its task port to the parent almost immediately after startup. |
271 // The Mach message will be delivered to the parent, but updating the | 271 // The Mach message will be delivered to the parent, but updating the |
272 // record of the launch will wait until after the placeholder PID is | 272 // record of the launch will wait until after the placeholder PID is |
273 // inserted below. This ensures that while the child process may send its | 273 // inserted below. This ensures that while the child process may send its |
274 // port to the parent prior to the parent leaving LaunchProcess, the | 274 // port to the parent prior to the parent leaving LaunchProcess, the |
275 // order in which the record in MachBroker is updated is correct. | 275 // order in which the record in MachBroker is updated is correct. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 bool zygote_; | 407 bool zygote_; |
408 #endif | 408 #endif |
409 }; | 409 }; |
410 | 410 |
411 | 411 |
412 ChildProcessLauncher::ChildProcessLauncher( | 412 ChildProcessLauncher::ChildProcessLauncher( |
413 #if defined(OS_WIN) | 413 #if defined(OS_WIN) |
414 SandboxedProcessLauncherDelegate* delegate, | 414 SandboxedProcessLauncherDelegate* delegate, |
415 #elif defined(OS_POSIX) | 415 #elif defined(OS_POSIX) |
416 bool use_zygote, | 416 bool use_zygote, |
417 const base::EnvironmentVector& environ, | 417 const base::EnvironmentMap& environ, |
418 int ipcfd, | 418 int ipcfd, |
419 #endif | 419 #endif |
420 CommandLine* cmd_line, | 420 CommandLine* cmd_line, |
421 int child_process_id, | 421 int child_process_id, |
422 Client* client) { | 422 Client* client) { |
423 context_ = new Context(); | 423 context_ = new Context(); |
424 context_->Launch( | 424 context_->Launch( |
425 #if defined(OS_WIN) | 425 #if defined(OS_WIN) |
426 delegate, | 426 delegate, |
427 #elif defined(OS_ANDROID) | 427 #elif defined(OS_ANDROID) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 GetHandle(), background)); | 493 GetHandle(), background)); |
494 } | 494 } |
495 | 495 |
496 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 496 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
497 bool terminate_on_shutdown) { | 497 bool terminate_on_shutdown) { |
498 if (context_.get()) | 498 if (context_.get()) |
499 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 499 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
500 } | 500 } |
501 | 501 |
502 } // namespace content | 502 } // namespace content |
OLD | NEW |