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 "content/browser/child_process_launcher_helper.h" | 5 #include "content/browser/child_process_launcher_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
| 9 #include "base/android/apk_assets.h" |
9 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
12 #include "content/browser/android/child_process_launcher_android.h" | 13 #include "content/browser/android/child_process_launcher_android.h" |
13 #include "content/browser/child_process_launcher_helper_posix.h" | 14 #include "content/browser/child_process_launcher_helper_posix.h" |
14 #include "content/browser/file_descriptor_info_impl.h" | 15 #include "content/browser/file_descriptor_info_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/common/content_descriptors.h" | 19 #include "content/public/common/content_descriptors.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 83 |
83 std::unique_ptr<FileDescriptorInfo> | 84 std::unique_ptr<FileDescriptorInfo> |
84 ChildProcessLauncherHelper::GetFilesToMap() { | 85 ChildProcessLauncherHelper::GetFilesToMap() { |
85 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); | 86 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
86 | 87 |
87 // Android WebView runs in single process, ensure that we never get here when | 88 // Android WebView runs in single process, ensure that we never get here when |
88 // running in single process mode. | 89 // running in single process mode. |
89 CHECK(!command_line()->HasSwitch(switches::kSingleProcess)); | 90 CHECK(!command_line()->HasSwitch(switches::kSingleProcess)); |
90 | 91 |
91 std::unique_ptr<FileDescriptorInfo> files_to_register = | 92 std::unique_ptr<FileDescriptorInfo> files_to_register = |
92 CreateDefaultPosixFilesToMap(*command_line(), child_process_id(), | 93 CreateDefaultPosixFilesToMap(child_process_id(), |
93 mojo_client_handle()); | 94 mojo_client_handle(), |
94 | 95 true /* include_service_required_files */, |
95 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 96 GetProcessType(), |
96 base::MemoryMappedFile::Region region; | 97 command_line()); |
97 auto maybe_register = [®ion, &files_to_register](int key, int fd) { | |
98 if (fd != -1) | |
99 files_to_register->ShareWithRegion(key, fd, region); | |
100 }; | |
101 maybe_register( | |
102 kV8NativesDataDescriptor, | |
103 gin::V8Initializer::GetOpenNativesFileForChildProcesses(®ion)); | |
104 maybe_register( | |
105 kV8SnapshotDataDescriptor32, | |
106 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, true)); | |
107 maybe_register( | |
108 kV8SnapshotDataDescriptor64, | |
109 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, false)); | |
110 | |
111 command_line()->AppendSwitch(::switches::kV8NativesPassedByFD); | |
112 command_line()->AppendSwitch(::switches::kV8SnapshotPassedByFD); | |
113 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
114 | 98 |
115 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 99 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
116 int fd = base::i18n::GetIcuDataFileHandle(®ion); | 100 base::MemoryMappedFile::Region icu_region; |
117 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, region); | 101 int fd = base::i18n::GetIcuDataFileHandle(&icu_region); |
| 102 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, icu_region); |
118 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 103 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
119 | 104 |
120 return files_to_register; | 105 return files_to_register; |
121 } | 106 } |
122 | 107 |
123 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 108 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
124 const FileDescriptorInfo& files_to_register, | 109 const FileDescriptorInfo& files_to_register, |
125 base::LaunchOptions* options) { | 110 base::LaunchOptions* options) { |
126 } | 111 } |
127 | 112 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 << process.process.Handle(); | 157 << process.process.Handle(); |
173 StopChildProcess(process.process.Handle()); | 158 StopChildProcess(process.process.Handle()); |
174 } | 159 } |
175 | 160 |
176 // static | 161 // static |
177 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 162 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
178 base::Process process, bool background) { | 163 base::Process process, bool background) { |
179 SetChildProcessInForeground(process.Handle(), !background); | 164 SetChildProcessInForeground(process.Handle(), !background); |
180 } | 165 } |
181 | 166 |
| 167 // static |
| 168 void ChildProcessLauncherHelper::SetRegisteredFilesForService( |
| 169 const std::string& service_name, |
| 170 std::unique_ptr<catalog::RequiredFileMap> required_files) { |
| 171 SetFilesToShareForServicePosix(service_name, std::move(required_files)); |
| 172 } |
| 173 |
| 174 // static |
| 175 base::File OpenFileToShare(const base::FilePath& path, |
| 176 base::MemoryMappedFile::Region* region) { |
| 177 base::File file(base::android::OpenApkAsset(path.value(), region)); |
| 178 return file; |
| 179 } |
| 180 |
182 } // namespace internal | 181 } // namespace internal |
183 } // namespace content | 182 } // namespace content |
OLD | NEW |