OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "content/browser/child_process_launcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 149 |
150 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 150 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
151 std::map<int, base::MemoryMappedFile::Region> regions; | 151 std::map<int, base::MemoryMappedFile::Region> regions; |
152 GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess( | 152 GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess( |
153 *cmd_line, child_process_id, files_to_register.get() | 153 *cmd_line, child_process_id, files_to_register.get() |
154 #if defined(OS_ANDROID) | 154 #if defined(OS_ANDROID) |
155 , ®ions | 155 , ®ions |
156 #endif | 156 #endif |
157 ); | 157 ); |
158 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 158 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
159 bool snapshot_loaded = false; | |
160 #if defined(OS_ANDROID) | |
161 base::MemoryMappedFile::Region region; | |
162 auto maybe_register = [®ion, ®ions, &files_to_register](int key, | |
163 int fd) { | |
164 if (fd != -1) { | |
165 files_to_register->Share(key, fd); | |
166 regions.insert(std::make_pair(key, region)); | |
167 } | |
168 }; | |
169 maybe_register( | |
170 kV8NativesDataDescriptor32, | |
171 gin::V8Initializer::GetOpenNativesFileForChildProcesses(®ion, true)); | |
172 maybe_register( | |
173 kV8NativesDataDescriptor64, | |
174 gin::V8Initializer::GetOpenNativesFileForChildProcesses(®ion, false)); | |
175 maybe_register( | |
176 kV8SnapshotDataDescriptor32, | |
177 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, true)); | |
178 maybe_register( | |
179 kV8SnapshotDataDescriptor64, | |
180 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, false)); | |
181 | |
182 snapshot_loaded = true; | |
Torne
2016/02/03 11:05:32
Setting this to true unconditionally seems maybe w
Tobias Sargeant
2016/02/03 11:14:11
It's irritating, but I'm not sure what set of FDs
| |
183 #else | |
159 base::PlatformFile natives_pf = | 184 base::PlatformFile natives_pf = |
160 gin::V8Initializer::GetOpenNativesFileForChildProcesses( | 185 gin::V8Initializer::GetOpenNativesFileForChildProcesses( |
161 ®ions[kV8NativesDataDescriptor]); | 186 ®ions[kV8NativesDataDescriptor]); |
162 DCHECK_GE(natives_pf, 0); | 187 DCHECK_GE(natives_pf, 0); |
163 files_to_register->Share(kV8NativesDataDescriptor, natives_pf); | 188 files_to_register->Share(kV8NativesDataDescriptor, natives_pf); |
164 | 189 |
165 base::MemoryMappedFile::Region snapshot_region; | 190 base::MemoryMappedFile::Region snapshot_region; |
166 base::PlatformFile snapshot_pf = | 191 base::PlatformFile snapshot_pf = |
167 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses( | 192 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses( |
168 &snapshot_region); | 193 &snapshot_region); |
169 // Failure to load the V8 snapshot is not necessarily an error. V8 can start | 194 // Failure to load the V8 snapshot is not necessarily an error. V8 can start |
170 // up (slower) without the snapshot. | 195 // up (slower) without the snapshot. |
171 if (snapshot_pf != -1) { | 196 if (snapshot_pf != -1) { |
197 snapshot_loaded = true; | |
172 files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf); | 198 files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf); |
173 regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region)); | 199 regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region)); |
174 } | 200 } |
201 #endif | |
175 | 202 |
176 if (process_type != switches::kZygoteProcess) { | 203 if (process_type != switches::kZygoteProcess) { |
177 cmd_line->AppendSwitch(::switches::kV8NativesPassedByFD); | 204 cmd_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
178 if (snapshot_pf != -1) { | 205 if (snapshot_loaded) { |
179 cmd_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); | 206 cmd_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
180 } | 207 } |
181 } | 208 } |
182 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA) | 209 #endif // defined(V8_USE_EXTERNAL_STARTUP_DATA) |
183 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 210 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
184 | 211 |
185 #if defined(OS_ANDROID) | 212 #if defined(OS_ANDROID) |
186 files_to_register->Share( | 213 files_to_register->Share( |
187 kAndroidICUDataDescriptor, | 214 kAndroidICUDataDescriptor, |
188 base::i18n::GetIcuDataFileHandle(®ions[kAndroidICUDataDescriptor])); | 215 base::i18n::GetIcuDataFileHandle(®ions[kAndroidICUDataDescriptor])); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 } | 554 } |
528 | 555 |
529 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( | 556 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( |
530 Client* client) { | 557 Client* client) { |
531 Client* ret = client_; | 558 Client* ret = client_; |
532 client_ = client; | 559 client_ = client; |
533 return ret; | 560 return ret; |
534 } | 561 } |
535 | 562 |
536 } // namespace content | 563 } // namespace content |
OLD | NEW |