Chromium Code Reviews| 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(), mojo_client_handle(), |
| 93 mojo_client_handle()); | 94 true /* include_service_required_files */, |
| 94 | 95 GetProcessType(), command_line()); |
| 95 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | |
|
boliu
2017/02/09 23:59:54
it's not clear to me where this chunk of code went
Jay Civelli
2017/02/10 06:32:34
Yes, it's not needed.
Now these files are specifie
| |
| 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 | 96 |
| 115 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 97 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
| 116 int fd = base::i18n::GetIcuDataFileHandle(®ion); | 98 base::MemoryMappedFile::Region icu_region; |
| 117 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, region); | 99 int fd = base::i18n::GetIcuDataFileHandle(&icu_region); |
| 100 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, icu_region); | |
| 118 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE | 101 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE |
| 119 | 102 |
| 120 return files_to_register; | 103 return files_to_register; |
| 121 } | 104 } |
| 122 | 105 |
| 123 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 106 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
| 124 const FileDescriptorInfo& files_to_register, | 107 const FileDescriptorInfo& files_to_register, |
| 125 base::LaunchOptions* options) { | 108 base::LaunchOptions* options) { |
| 126 } | 109 } |
| 127 | 110 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 << process.process.Handle(); | 155 << process.process.Handle(); |
| 173 StopChildProcess(process.process.Handle()); | 156 StopChildProcess(process.process.Handle()); |
| 174 } | 157 } |
| 175 | 158 |
| 176 // static | 159 // static |
| 177 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 160 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
| 178 base::Process process, bool background) { | 161 base::Process process, bool background) { |
| 179 SetChildProcessInForeground(process.Handle(), !background); | 162 SetChildProcessInForeground(process.Handle(), !background); |
| 180 } | 163 } |
| 181 | 164 |
| 165 // static | |
| 166 void ChildProcessLauncherHelper::SetRegisteredFilesForService( | |
| 167 const std::string& service_name, | |
| 168 std::unique_ptr<catalog::RequiredFileMap> required_files) { | |
| 169 SetFilesToShareForServicePosix(service_name, std::move(required_files)); | |
| 170 } | |
| 171 | |
| 172 // static | |
| 173 base::File OpenFileToShare(const base::FilePath& path, | |
| 174 base::MemoryMappedFile::Region* region) { | |
| 175 base::File file(base::android::OpenApkAsset(path.value(), region)); | |
|
boliu
2017/02/09 23:59:54
nit: one line return so RVO works?
Jay Civelli
2017/02/10 06:32:34
Done.
| |
| 176 return file; | |
| 177 } | |
| 178 | |
| 182 } // namespace internal | 179 } // namespace internal |
| 183 } // namespace content | 180 } // namespace content |
| OLD | NEW |