| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 bootstrap_sandbox_policy != SANDBOX_TYPE_INVALID) { | |
| 261 GetBootstrapSandbox()->FinishedFork(process.Handle()); | |
| 262 } | |
| 263 | |
| 264 if (process.IsValid()) | 260 if (process.IsValid()) |
| 265 broker->AddPlaceholderForPid(process.Pid(), child_process_id); | 261 broker->AddPlaceholderForPid(process.Pid(), child_process_id); |
| 266 | 262 |
| 267 // After updating the broker, release the lock and let the child's | 263 // After updating the broker, release the lock and let the child's |
| 268 // messasge be processed on the broker's thread. | 264 // messasge be processed on the broker's thread. |
| 269 broker->GetLock().Release(); | 265 broker->GetLock().Release(); |
| 270 #endif // defined(OS_MACOSX) | 266 #endif // defined(OS_MACOSX) |
| 271 } | 267 } |
| 272 #endif // else defined(OS_POSIX) | 268 #endif // else defined(OS_POSIX) |
| 273 #if !defined(OS_ANDROID) | 269 #if !defined(OS_ANDROID) |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 541 } |
| 546 | 542 |
| 547 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( | 543 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( |
| 548 Client* client) { | 544 Client* client) { |
| 549 Client* ret = client_; | 545 Client* ret = client_; |
| 550 client_ = client; | 546 client_ = client; |
| 551 return ret; | 547 return ret; |
| 552 } | 548 } |
| 553 | 549 |
| 554 } // namespace content | 550 } // namespace content |
| OLD | NEW |