| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "base/path_service.h" |
| 6 #include "base/posix/global_descriptors.h" | 7 #include "base/posix/global_descriptors.h" |
| 7 #include "content/browser/bootstrap_sandbox_manager_mac.h" | 8 #include "content/browser/bootstrap_sandbox_manager_mac.h" |
| 8 #include "content/browser/child_process_launcher.h" | 9 #include "content/browser/child_process_launcher.h" |
| 9 #include "content/browser/child_process_launcher_helper.h" | 10 #include "content/browser/child_process_launcher_helper.h" |
| 10 #include "content/browser/child_process_launcher_helper_posix.h" | 11 #include "content/browser/child_process_launcher_helper_posix.h" |
| 11 #include "content/browser/mach_broker_mac.h" | 12 #include "content/browser/mach_broker_mac.h" |
| 12 #include "content/public/common/result_codes.h" | 13 #include "content/public/common/result_codes.h" |
| 13 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 14 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 14 #include "mojo/edk/embedder/scoped_platform_handle.h" | 15 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #include "sandbox/mac/bootstrap_sandbox.h" | 16 #include "sandbox/mac/bootstrap_sandbox.h" |
| 16 #include "sandbox/mac/pre_exec_delegate.h" | 17 #include "sandbox/mac/pre_exec_delegate.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 mojo::edk::ScopedPlatformHandle | 22 mojo::edk::ScopedPlatformHandle |
| 22 ChildProcessLauncherHelper::PrepareMojoPipeHandlesOnClientThread() { | 23 ChildProcessLauncherHelper::PrepareMojoPipeHandlesOnClientThread() { |
| 23 DCHECK_CURRENTLY_ON(client_thread_id_); | 24 DCHECK_CURRENTLY_ON(client_thread_id_); |
| 24 return mojo::edk::ScopedPlatformHandle(); | 25 return mojo::edk::ScopedPlatformHandle(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { | 28 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { |
| 28 DCHECK_CURRENTLY_ON(client_thread_id_); | 29 DCHECK_CURRENTLY_ON(client_thread_id_); |
| 29 } | 30 } |
| 30 | 31 |
| 31 std::unique_ptr<FileDescriptorInfo> | 32 std::unique_ptr<FileDescriptorInfo> |
| 32 ChildProcessLauncherHelper::GetFilesToMap() { | 33 ChildProcessLauncherHelper::GetFilesToMap() { |
| 33 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); | 34 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
| 34 return CreateDefaultPosixFilesToMap(*command_line(), child_process_id(), | 35 return CreateDefaultPosixFilesToMap( |
| 35 mojo_client_handle()); | 36 child_process_id(), mojo_client_handle(), |
| 37 false /* include_service_required_files */, GetProcessType(), |
| 38 command_line()); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 41 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
| 39 const FileMappedForLaunch& files_to_register, | 42 const FileMappedForLaunch& files_to_register, |
| 40 base::LaunchOptions* options) { | 43 base::LaunchOptions* options) { |
| 41 // Convert FD mapping to FileHandleMappingVector. | 44 // Convert FD mapping to FileHandleMappingVector. |
| 42 std::unique_ptr<base::FileHandleMappingVector> fds_to_map = | 45 std::unique_ptr<base::FileHandleMappingVector> fds_to_map = |
| 43 files_to_register.GetMappingWithIDAdjustment( | 46 files_to_register.GetMappingWithIDAdjustment( |
| 44 base::GlobalDescriptors::kBaseDescriptor); | 47 base::GlobalDescriptors::kBaseDescriptor); |
| 45 | 48 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 base::EnsureProcessTerminated(std::move(process.process)); | 142 base::EnsureProcessTerminated(std::move(process.process)); |
| 140 } | 143 } |
| 141 | 144 |
| 142 // static | 145 // static |
| 143 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 146 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
| 144 base::Process process, bool background) { | 147 base::Process process, bool background) { |
| 145 if (process.CanBackgroundProcesses()) | 148 if (process.CanBackgroundProcesses()) |
| 146 process.SetProcessBackgrounded(MachBroker::GetInstance(), background); | 149 process.SetProcessBackgrounded(MachBroker::GetInstance(), background); |
| 147 } | 150 } |
| 148 | 151 |
| 152 // static |
| 153 void ChildProcessLauncherHelper::SetRegisteredFilesForService( |
| 154 const std::string& service_name, |
| 155 std::unique_ptr<catalog::RequiredFileMap> required_files) { |
| 156 // No file passing from the manifest on Mac yet. |
| 157 DCHECK(required_files->empty()); |
| 158 } |
| 159 |
| 160 // static |
| 161 base::File OpenFileToShare(const base::FilePath& path, |
| 162 base::MemoryMappedFile::Region* region) { |
| 163 // Not used yet (until required files are described in the service manifest on |
| 164 // Mac). |
| 165 NOTREACHED(); |
| 166 return base::File(); |
| 167 } |
| 168 |
| 149 } // namespace internal | 169 } // namespace internal |
| 150 } // namespace content | 170 } // namespace content |
| OLD | NEW |