Chromium Code Reviews| Index: content/browser/child_process_launcher.cc |
| diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc |
| index 4398e2b390acd1c03e6748e5b0c008ddd1bb0eb8..e92554c8aa5a423b6b6f91d2f2e77b67cb414c03 100644 |
| --- a/content/browser/child_process_launcher.cc |
| +++ b/content/browser/child_process_launcher.cc |
| @@ -156,6 +156,31 @@ void LaunchOnLauncherThread(const NotifyCallback& callback, |
| #endif |
| ); |
| #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
| + bool snapshot_loaded = false; |
| +#if defined(OS_ANDROID) |
| + base::MemoryMappedFile::Region region; |
| + auto maybe_register = [®ion, ®ions, &files_to_register](int key, |
| + int fd) { |
| + if (fd != -1) { |
| + files_to_register->Share(key, fd); |
| + regions.insert(std::make_pair(key, region)); |
| + } |
| + }; |
| + maybe_register( |
| + kV8NativesDataDescriptor32, |
| + gin::V8Initializer::GetOpenNativesFileForChildProcesses(®ion, true)); |
| + maybe_register( |
| + kV8NativesDataDescriptor64, |
| + gin::V8Initializer::GetOpenNativesFileForChildProcesses(®ion, false)); |
| + maybe_register( |
| + kV8SnapshotDataDescriptor32, |
| + gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, true)); |
| + maybe_register( |
| + kV8SnapshotDataDescriptor64, |
| + gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(®ion, false)); |
| + |
| + 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
|
| +#else |
| base::PlatformFile natives_pf = |
| gin::V8Initializer::GetOpenNativesFileForChildProcesses( |
| ®ions[kV8NativesDataDescriptor]); |
| @@ -169,13 +194,15 @@ void LaunchOnLauncherThread(const NotifyCallback& callback, |
| // Failure to load the V8 snapshot is not necessarily an error. V8 can start |
| // up (slower) without the snapshot. |
| if (snapshot_pf != -1) { |
| + snapshot_loaded = true; |
| files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf); |
| regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region)); |
| } |
| +#endif |
| if (process_type != switches::kZygoteProcess) { |
| cmd_line->AppendSwitch(::switches::kV8NativesPassedByFD); |
| - if (snapshot_pf != -1) { |
| + if (snapshot_loaded) { |
| cmd_line->AppendSwitch(::switches::kV8SnapshotPassedByFD); |
| } |
| } |