Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: content/browser/child_process_launcher.cc

Issue 1665513002: Pass both 32 and 64 bit snapshot and natives fds to child processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: avoid non-POD global Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/public/common/content_descriptors.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 , &regions 155 , &regions
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 = [&region, &regions, &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(&region, true));
172 maybe_register(
173 kV8NativesDataDescriptor64,
174 gin::V8Initializer::GetOpenNativesFileForChildProcesses(&region, false));
175 maybe_register(
176 kV8SnapshotDataDescriptor32,
177 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(&region, true));
178 maybe_register(
179 kV8SnapshotDataDescriptor64,
180 gin::V8Initializer::GetOpenSnapshotFileForChildProcesses(&region, false));
181
182 snapshot_loaded = true;
183 #else
159 base::PlatformFile natives_pf = 184 base::PlatformFile natives_pf =
160 gin::V8Initializer::GetOpenNativesFileForChildProcesses( 185 gin::V8Initializer::GetOpenNativesFileForChildProcesses(
161 &regions[kV8NativesDataDescriptor]); 186 &regions[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(&regions[kAndroidICUDataDescriptor])); 215 base::i18n::GetIcuDataFileHandle(&regions[kAndroidICUDataDescriptor]));
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/public/common/content_descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698