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/path_service.h" | 5 #include "base/path_service.h" |
6 #include "base/posix/global_descriptors.h" | 6 #include "base/posix/global_descriptors.h" |
7 #include "content/browser/child_process_launcher.h" | 7 #include "content/browser/child_process_launcher.h" |
8 #include "content/browser/child_process_launcher_helper.h" | 8 #include "content/browser/child_process_launcher_helper.h" |
9 #include "content/browser/child_process_launcher_helper_posix.h" | 9 #include "content/browser/child_process_launcher_helper_posix.h" |
10 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 10 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 std::unique_ptr<FileMappedForLaunch> | 34 std::unique_ptr<FileMappedForLaunch> |
35 ChildProcessLauncherHelper::GetFilesToMap() { | 35 ChildProcessLauncherHelper::GetFilesToMap() { |
36 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); | 36 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
37 return CreateDefaultPosixFilesToMap(child_process_id(), mojo_client_handle(), | 37 return CreateDefaultPosixFilesToMap(child_process_id(), mojo_client_handle(), |
38 true /* include_service_required_files */, | 38 true /* include_service_required_files */, |
39 GetProcessType(), command_line()); | 39 GetProcessType(), command_line()); |
40 } | 40 } |
41 | 41 |
42 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 42 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
43 const FileDescriptorInfo& files_to_register, | 43 const PosixFileDescriptorInfo& files_to_register, |
44 base::LaunchOptions* options) { | 44 base::LaunchOptions* options) { |
45 // Convert FD mapping to FileHandleMappingVector | 45 // Convert FD mapping to FileHandleMappingVector |
46 std::unique_ptr<base::FileHandleMappingVector> fds_to_map = | 46 options->fds_to_remap = files_to_register.GetMappingWithIDAdjustment( |
47 files_to_register.GetMappingWithIDAdjustment( | 47 base::GlobalDescriptors::kBaseDescriptor); |
48 base::GlobalDescriptors::kBaseDescriptor); | |
49 | 48 |
50 if (GetProcessType() == switches::kRendererProcess) { | 49 if (GetProcessType() == switches::kRendererProcess) { |
51 const int sandbox_fd = | 50 const int sandbox_fd = |
52 RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); | 51 RenderSandboxHostLinux::GetInstance()->GetRendererSocket(); |
53 fds_to_map->push_back(std::make_pair(sandbox_fd, GetSandboxFD())); | 52 options->fds_to_remap.push_back(std::make_pair(sandbox_fd, GetSandboxFD())); |
54 } | 53 } |
55 | 54 |
56 options->environ = delegate_->GetEnvironment(); | 55 options->environ = delegate_->GetEnvironment(); |
57 // fds_to_remap will de deleted in AfterLaunchOnLauncherThread() below. | |
58 options->fds_to_remap = fds_to_map.release(); | |
59 } | 56 } |
60 | 57 |
61 ChildProcessLauncherHelper::Process | 58 ChildProcessLauncherHelper::Process |
62 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( | 59 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( |
63 const base::LaunchOptions& options, | 60 const base::LaunchOptions& options, |
64 std::unique_ptr<FileMappedForLaunch> files_to_register, | 61 std::unique_ptr<FileMappedForLaunch> files_to_register, |
65 bool* is_synchronous_launch, | 62 bool* is_synchronous_launch, |
66 int* launch_result) { | 63 int* launch_result) { |
67 *is_synchronous_launch = true; | 64 *is_synchronous_launch = true; |
68 | 65 |
(...skipping 17 matching lines...) Expand all Loading... |
86 Process process; | 83 Process process; |
87 process.process = base::LaunchProcess(*command_line(), options); | 84 process.process = base::LaunchProcess(*command_line(), options); |
88 *launch_result = process.process.IsValid() ? LAUNCH_RESULT_SUCCESS | 85 *launch_result = process.process.IsValid() ? LAUNCH_RESULT_SUCCESS |
89 : LAUNCH_RESULT_FAILURE; | 86 : LAUNCH_RESULT_FAILURE; |
90 return process; | 87 return process; |
91 } | 88 } |
92 | 89 |
93 void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( | 90 void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( |
94 const ChildProcessLauncherHelper::Process& process, | 91 const ChildProcessLauncherHelper::Process& process, |
95 const base::LaunchOptions& options) { | 92 const base::LaunchOptions& options) { |
96 delete options.fds_to_remap; | |
97 } | 93 } |
98 | 94 |
99 base::TerminationStatus ChildProcessLauncherHelper::GetTerminationStatus( | 95 base::TerminationStatus ChildProcessLauncherHelper::GetTerminationStatus( |
100 const ChildProcessLauncherHelper::Process& process, | 96 const ChildProcessLauncherHelper::Process& process, |
101 bool known_dead, | 97 bool known_dead, |
102 int* exit_code) { | 98 int* exit_code) { |
103 if (process.zygote) { | 99 if (process.zygote) { |
104 return process.zygote->GetTerminationStatus( | 100 return process.zygote->GetTerminationStatus( |
105 process.process.Handle(), known_dead, exit_code); | 101 process.process.Handle(), known_dead, exit_code); |
106 } | 102 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool result = base::PathService::Get(base::BasePathKey::DIR_EXE, &exe_dir); | 155 bool result = base::PathService::Get(base::BasePathKey::DIR_EXE, &exe_dir); |
160 DCHECK(result); | 156 DCHECK(result); |
161 base::File file(exe_dir.Append(path), | 157 base::File file(exe_dir.Append(path), |
162 base::File::FLAG_OPEN | base::File::FLAG_READ); | 158 base::File::FLAG_OPEN | base::File::FLAG_READ); |
163 *region = base::MemoryMappedFile::Region::kWholeFile; | 159 *region = base::MemoryMappedFile::Region::kWholeFile; |
164 return file; | 160 return file; |
165 } | 161 } |
166 | 162 |
167 } // namespace internal | 163 } // namespace internal |
168 } // namespace content | 164 } // namespace content |
OLD | NEW |