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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 } | 59 } |
60 | 60 |
61 ChildProcessLauncherHelper::Process | 61 ChildProcessLauncherHelper::Process |
62 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( | 62 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( |
63 const base::LaunchOptions& options, | 63 const base::LaunchOptions& options, |
64 std::unique_ptr<FileMappedForLaunch> files_to_register, | 64 std::unique_ptr<FileMappedForLaunch> files_to_register, |
65 bool* is_synchronous_launch, | 65 bool* is_synchronous_launch, |
66 int* launch_result) { | 66 int* launch_result) { |
67 *is_synchronous_launch = true; | 67 *is_synchronous_launch = true; |
68 | 68 |
69 ZygoteHandle* zygote_handle = | 69 ZygoteHandle zygote_handle = |
70 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote) ? | 70 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote) |
71 nullptr : delegate_->GetZygote(); | 71 ? nullptr |
72 : delegate_->GetZygote(); | |
72 if (zygote_handle) { | 73 if (zygote_handle) { |
73 // This code runs on the PROCESS_LAUNCHER thread so race conditions are not | 74 // TODO(crbug.com/569191): If chrome supported multiple zygotes they could |
74 // an issue with the lazy initialization. | 75 // be created lazily here, or in the delegate GetZygote() implementations. |
75 if (*zygote_handle == nullptr) { | 76 // Additionally, the delegate could provide a UseGenericZygote() method. |
James Cook
2017/04/28 20:07:52
This bit is a little subtle, and is the thing I'm
| |
76 *zygote_handle = CreateZygote(); | 77 base::ProcessHandle handle = zygote_handle->ForkRequest( |
77 } | 78 command_line()->argv(), std::move(files_to_register), GetProcessType()); |
78 base::ProcessHandle handle = (*zygote_handle)->ForkRequest( | |
79 command_line()->argv(), | |
80 std::move(files_to_register), | |
81 GetProcessType()); | |
82 *launch_result = LAUNCH_RESULT_SUCCESS; | 79 *launch_result = LAUNCH_RESULT_SUCCESS; |
83 Process process; | 80 Process process; |
84 process.process = base::Process(handle); | 81 process.process = base::Process(handle); |
85 process.zygote = *zygote_handle; | 82 process.zygote = zygote_handle; |
86 return process; | 83 return process; |
87 } | 84 } |
88 | 85 |
89 Process process; | 86 Process process; |
90 process.process = base::LaunchProcess(*command_line(), options); | 87 process.process = base::LaunchProcess(*command_line(), options); |
91 *launch_result = process.process.IsValid() ? LAUNCH_RESULT_SUCCESS | 88 *launch_result = process.process.IsValid() ? LAUNCH_RESULT_SUCCESS |
92 : LAUNCH_RESULT_FAILURE; | 89 : LAUNCH_RESULT_FAILURE; |
93 return process; | 90 return process; |
94 } | 91 } |
95 | 92 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 bool result = base::PathService::Get(base::BasePathKey::DIR_EXE, &exe_dir); | 157 bool result = base::PathService::Get(base::BasePathKey::DIR_EXE, &exe_dir); |
161 DCHECK(result); | 158 DCHECK(result); |
162 base::File file(exe_dir.Append(path), | 159 base::File file(exe_dir.Append(path), |
163 base::File::FLAG_OPEN | base::File::FLAG_READ); | 160 base::File::FLAG_OPEN | base::File::FLAG_READ); |
164 *region = base::MemoryMappedFile::Region::kWholeFile; | 161 *region = base::MemoryMappedFile::Region::kWholeFile; |
165 return file; | 162 return file; |
166 } | 163 } |
167 | 164 |
168 } // namespace internal | 165 } // namespace internal |
169 } // namespace content | 166 } // namespace content |
OLD | NEW |