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

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

Issue 303293002: Initialize the bootstrap sandbox in the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename constant Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/plugin_process_host.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 #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 10 matching lines...) Expand all
21 #include "content/public/common/content_descriptors.h" 21 #include "content/public/common/content_descriptors.h"
22 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
23 #include "content/public/common/result_codes.h" 23 #include "content/public/common/result_codes.h"
24 #include "content/public/common/sandboxed_process_launcher_delegate.h" 24 #include "content/public/common/sandboxed_process_launcher_delegate.h"
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 #include "base/files/file_path.h" 27 #include "base/files/file_path.h"
28 #include "content/common/sandbox_win.h" 28 #include "content/common/sandbox_win.h"
29 #include "content/public/common/sandbox_init.h" 29 #include "content/public/common/sandbox_init.h"
30 #elif defined(OS_MACOSX) 30 #elif defined(OS_MACOSX)
31 #include "content/browser/bootstrap_sandbox_mac.h"
31 #include "content/browser/mach_broker_mac.h" 32 #include "content/browser/mach_broker_mac.h"
33 #include "sandbox/mac/bootstrap_sandbox.h"
32 #elif defined(OS_ANDROID) 34 #elif defined(OS_ANDROID)
33 #include "base/android/jni_android.h" 35 #include "base/android/jni_android.h"
34 #include "content/browser/android/child_process_launcher_android.h" 36 #include "content/browser/android/child_process_launcher_android.h"
35 #elif defined(OS_POSIX) 37 #elif defined(OS_POSIX)
36 #include "base/memory/shared_memory.h" 38 #include "base/memory/shared_memory.h"
37 #include "base/memory/singleton.h" 39 #include "base/memory/singleton.h"
38 #include "content/browser/renderer_host/render_sandbox_host_linux.h" 40 #include "content/browser/renderer_host/render_sandbox_host_linux.h"
39 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 41 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
40 #include "content/common/child_process_sandbox_support_impl_linux.h" 42 #include "content/common/child_process_sandbox_support_impl_linux.h"
41 #endif 43 #endif
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // record of the launch will wait until after the placeholder PID is 277 // record of the launch will wait until after the placeholder PID is
276 // inserted below. This ensures that while the child process may send its 278 // inserted below. This ensures that while the child process may send its
277 // port to the parent prior to the parent leaving LaunchProcess, the 279 // port to the parent prior to the parent leaving LaunchProcess, the
278 // order in which the record in MachBroker is updated is correct. 280 // order in which the record in MachBroker is updated is correct.
279 MachBroker* broker = MachBroker::GetInstance(); 281 MachBroker* broker = MachBroker::GetInstance();
280 broker->GetLock().Acquire(); 282 broker->GetLock().Acquire();
281 283
282 // Make sure the MachBroker is running, and inform it to expect a 284 // Make sure the MachBroker is running, and inform it to expect a
283 // check-in from the new process. 285 // check-in from the new process.
284 broker->EnsureRunning(); 286 broker->EnsureRunning();
287
288 const int bootstrap_sandbox_policy = delegate->GetSandboxType();
289 if (ShouldEnableBootstrapSandbox() &&
290 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) {
291 GetBootstrapSandbox()->PrepareToForkWithPolicy(
292 bootstrap_sandbox_policy);
293 }
285 #endif // defined(OS_MACOSX) 294 #endif // defined(OS_MACOSX)
286 295
287 bool launched = base::LaunchProcess(*cmd_line, options, &handle); 296 bool launched = base::LaunchProcess(*cmd_line, options, &handle);
297 if (!launched)
298 handle = base::kNullProcessHandle;
288 299
289 #if defined(OS_MACOSX) 300 #if defined(OS_MACOSX)
301 if (ShouldEnableBootstrapSandbox() &&
302 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) {
303 GetBootstrapSandbox()->FinishedFork(handle);
304 }
305
290 if (launched) 306 if (launched)
291 broker->AddPlaceholderForPid(handle); 307 broker->AddPlaceholderForPid(handle);
292 308
293 // After updating the broker, release the lock and let the child's 309 // After updating the broker, release the lock and let the child's
294 // messasge be processed on the broker's thread. 310 // messasge be processed on the broker's thread.
295 broker->GetLock().Release(); 311 broker->GetLock().Release();
296 #endif // defined(OS_MACOSX) 312 #endif // defined(OS_MACOSX)
297
298 if (!launched)
299 handle = base::kNullProcessHandle;
300 } 313 }
301 #endif // else defined(OS_POSIX) 314 #endif // else defined(OS_POSIX)
302 #if !defined(OS_ANDROID) 315 #if !defined(OS_ANDROID)
303 if (handle) 316 if (handle)
304 RecordHistograms(begin_launch_time); 317 RecordHistograms(begin_launch_time);
305 BrowserThread::PostTask( 318 BrowserThread::PostTask(
306 client_thread_id, FROM_HERE, 319 client_thread_id, FROM_HERE,
307 base::Bind( 320 base::Bind(
308 &Context::Notify, 321 &Context::Notify,
309 this_object.get(), 322 this_object.get(),
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 GetHandle(), background)); 515 GetHandle(), background));
503 } 516 }
504 517
505 void ChildProcessLauncher::SetTerminateChildOnShutdown( 518 void ChildProcessLauncher::SetTerminateChildOnShutdown(
506 bool terminate_on_shutdown) { 519 bool terminate_on_shutdown) {
507 if (context_.get()) 520 if (context_.get())
508 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); 521 context_->set_terminate_child_on_shutdown(terminate_on_shutdown);
509 } 522 }
510 523
511 } // namespace content 524 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/plugin_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698