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

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

Issue 1346923006: Refactor the bootstrap sandbox process launching integration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RevokeToken Created 5 years, 3 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/bootstrap_sandbox_mac.cc ('k') | sandbox/mac/BUILD.gn » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/i18n/icu_util.h" 10 #include "base/i18n/icu_util.h"
(...skipping 12 matching lines...) Expand all
23 23
24 #if defined(OS_WIN) 24 #if defined(OS_WIN)
25 #include "base/files/file_path.h" 25 #include "base/files/file_path.h"
26 #include "content/common/sandbox_win.h" 26 #include "content/common/sandbox_win.h"
27 #include "content/public/common/sandbox_init.h" 27 #include "content/public/common/sandbox_init.h"
28 #elif defined(OS_MACOSX) 28 #elif defined(OS_MACOSX)
29 #include "content/browser/bootstrap_sandbox_mac.h" 29 #include "content/browser/bootstrap_sandbox_mac.h"
30 #include "content/browser/browser_io_surface_manager_mac.h" 30 #include "content/browser/browser_io_surface_manager_mac.h"
31 #include "content/browser/mach_broker_mac.h" 31 #include "content/browser/mach_broker_mac.h"
32 #include "sandbox/mac/bootstrap_sandbox.h" 32 #include "sandbox/mac/bootstrap_sandbox.h"
33 #include "sandbox/mac/pre_exec_delegate.h"
33 #elif defined(OS_ANDROID) 34 #elif defined(OS_ANDROID)
34 #include "base/android/jni_android.h" 35 #include "base/android/jni_android.h"
35 #include "content/browser/android/child_process_launcher_android.h" 36 #include "content/browser/android/child_process_launcher_android.h"
36 #elif defined(OS_POSIX) 37 #elif defined(OS_POSIX)
37 #include "base/memory/shared_memory.h" 38 #include "base/memory/shared_memory.h"
38 #include "base/memory/singleton.h" 39 #include "base/memory/singleton.h"
39 #include "content/browser/renderer_host/render_sandbox_host_linux.h" 40 #include "content/browser/renderer_host/render_sandbox_host_linux.h"
40 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 41 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
41 #include "content/common/child_process_sandbox_support_impl_linux.h" 42 #include "content/common/child_process_sandbox_support_impl_linux.h"
42 #endif 43 #endif
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 broker->GetLock().Acquire(); 238 broker->GetLock().Acquire();
238 239
239 // Make sure the MachBroker is running, and inform it to expect a 240 // Make sure the MachBroker is running, and inform it to expect a
240 // check-in from the new process. 241 // check-in from the new process.
241 broker->EnsureRunning(); 242 broker->EnsureRunning();
242 243
243 // Make sure the IOSurfaceManager service is running. 244 // Make sure the IOSurfaceManager service is running.
244 BrowserIOSurfaceManager::GetInstance()->EnsureRunning(); 245 BrowserIOSurfaceManager::GetInstance()->EnsureRunning();
245 246
246 const int bootstrap_sandbox_policy = delegate->GetSandboxType(); 247 const int bootstrap_sandbox_policy = delegate->GetSandboxType();
248 scoped_ptr<sandbox::PreExecDelegate> pre_exec_delegate;
247 if (ShouldEnableBootstrapSandbox() && 249 if (ShouldEnableBootstrapSandbox() &&
248 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) { 250 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) {
249 options.replacement_bootstrap_name = 251 pre_exec_delegate =
250 GetBootstrapSandbox()->server_bootstrap_name(); 252 GetBootstrapSandbox()->NewClient(bootstrap_sandbox_policy).Pass();
251 GetBootstrapSandbox()->PrepareToForkWithPolicy(
252 bootstrap_sandbox_policy);
253 } 253 }
254 options.pre_exec_delegate = pre_exec_delegate.get();
254 #endif // defined(OS_MACOSX) 255 #endif // defined(OS_MACOSX)
255 256
256 process = base::LaunchProcess(*cmd_line, options); 257 process = base::LaunchProcess(*cmd_line, options);
257 258
258 #if defined(OS_MACOSX) 259 #if defined(OS_MACOSX)
259 if (ShouldEnableBootstrapSandbox() && 260 if (process.IsValid()) {
260 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) { 261 broker->AddPlaceholderForPid(process.Pid(), child_process_id);
261 GetBootstrapSandbox()->FinishedFork(process.Handle()); 262 } else {
263 if (pre_exec_delegate) {
264 GetBootstrapSandbox()->RevokeToken(
265 pre_exec_delegate->sandbox_token());
266 }
262 } 267 }
263 268
264 if (process.IsValid())
265 broker->AddPlaceholderForPid(process.Pid(), child_process_id);
266
267 // After updating the broker, release the lock and let the child's 269 // After updating the broker, release the lock and let the child's
268 // messasge be processed on the broker's thread. 270 // messasge be processed on the broker's thread.
269 broker->GetLock().Release(); 271 broker->GetLock().Release();
270 #endif // defined(OS_MACOSX) 272 #endif // defined(OS_MACOSX)
271 } 273 }
272 #endif // else defined(OS_POSIX) 274 #endif // else defined(OS_POSIX)
273 #if !defined(OS_ANDROID) 275 #if !defined(OS_ANDROID)
274 if (process.IsValid()) { 276 if (process.IsValid()) {
275 RecordHistogramsOnLauncherThread(base::TimeTicks::Now() - 277 RecordHistogramsOnLauncherThread(base::TimeTicks::Now() -
276 begin_launch_time); 278 begin_launch_time);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 547 }
546 548
547 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 549 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
548 Client* client) { 550 Client* client) {
549 Client* ret = client_; 551 Client* ret = client_;
550 client_ = client; 552 client_ = client;
551 return ret; 553 return ret;
552 } 554 }
553 555
554 } // namespace content 556 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bootstrap_sandbox_mac.cc ('k') | sandbox/mac/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698