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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(*command_line(), child_process_id(), |
93 mojo_client_handle()); | 94 mojo_client_handle()); |
94 | 95 |
95 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
96 base::MemoryMappedFile::Region region; | |
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 | |
115 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 96 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
116 int fd = base::i18n::GetIcuDataFileHandle(®ion); | 97 base::MemoryMappedFile::Region icu_region; |
117 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, region); | 98 int fd = base::i18n::GetIcuDataFileHandle(&icu_region); |
| 99 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, icu_region); |
118 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 100 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
119 | 101 |
120 return files_to_register; | 102 return files_to_register; |
121 } | 103 } |
122 | 104 |
123 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 105 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
124 const FileDescriptorInfo& files_to_register, | 106 const FileDescriptorInfo& files_to_register, |
125 base::LaunchOptions* options) { | 107 base::LaunchOptions* options) { |
126 } | 108 } |
127 | 109 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 << process.process.Handle(); | 154 << process.process.Handle(); |
173 StopChildProcess(process.process.Handle()); | 155 StopChildProcess(process.process.Handle()); |
174 } | 156 } |
175 | 157 |
176 // static | 158 // static |
177 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 159 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
178 base::Process process, bool background) { | 160 base::Process process, bool background) { |
179 SetChildProcessInForeground(process.Handle(), !background); | 161 SetChildProcessInForeground(process.Handle(), !background); |
180 } | 162 } |
181 | 163 |
| 164 // static |
| 165 base::File ChildProcessLauncherHelper::OpenFile( |
| 166 const base::FilePath& path, |
| 167 base::MemoryMappedFile::Region* region) { |
| 168 base::File file(base::android::OpenApkAsset(path.value(), region)); |
| 169 return file; |
| 170 } |
| 171 |
182 } // namespace internal | 172 } // namespace internal |
183 } // namespace content | 173 } // namespace content |
OLD | NEW |