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

Unified Diff: content/browser/child_process_launcher.cc

Issue 1182443003: Moved logic for mapping child process FDs for ICU and V8 into child_process_launcher.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile 2 Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 48c5e94285e1b4e8f4ccf870196537f4edeffbad..d090d31aba339a7f7d22ffa370b7875e5fcf55d1 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
+#include "base/i18n/icu_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
@@ -43,6 +44,7 @@
#if defined(OS_POSIX)
#include "base/posix/global_descriptors.h"
#include "content/browser/file_descriptor_info_impl.h"
+#include "gin/v8_initializer.h"
#endif
namespace content {
@@ -141,15 +143,42 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
#endif
#endif
-#if defined(OS_ANDROID)
- // Android WebView runs in single process, ensure that we never get here
- // when running in single process mode.
- CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
std::map<int, base::MemoryMappedFile::Region> regions;
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+ files_to_register->Share(kV8NativesDataDescriptor,
+ gin::V8Initializer::OpenNativesFileForChildProcesses(
+ &regions[kV8NativesDataDescriptor]));
+
+ base::MemoryMappedFile::Region snapshot_region;
+ base::PlatformFile snapshot_pf =
+ gin::V8Initializer::OpenSnapshotFileForChildProcesses(&snapshot_region);
+ // Failure to load the V8 snapshot is not necessarily an error. V8 can start
+ // up (slower) without the snapshot.
+ if (snapshot_pf != -1) {
+ files_to_register->Share(kV8SnapshotDataDescriptor, snapshot_pf);
+ regions.insert(std::make_pair(kV8SnapshotDataDescriptor, snapshot_region));
+ }
+
+ if (process_type != switches::kZygoteProcess) {
+ cmd_line->AppendSwitch(::switches::kV8NativesPassedByFD);
+ if (snapshot_pf != -1) {
+ cmd_line->AppendSwitch(::switches::kV8SnapshotPassedByFD);
+ }
+ }
+#endif // defined(V8_USE_EXTERNAL_STARTUP_DATA)
GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
*cmd_line, child_process_id, files_to_register.get());
+#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
- GetContentClient()->browser()->AppendMappedFileCommandLineSwitches(cmd_line);
+#if defined(OS_ANDROID)
+ files_to_register->Share(
+ kAndroidICUDataDescriptor,
+ base::i18n::GetIcuDataFileHandle(&regions[kAndroidICUDataDescriptor]));
+
+ // Android WebView runs in single process, ensure that we never get here
+ // when running in single process mode.
+ CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
StartChildProcess(
cmd_line->argv(), child_process_id, files_to_register.Pass(), regions,
@@ -161,11 +190,6 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
// child termination.
#if !defined(OS_MACOSX)
- GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
- *cmd_line, child_process_id, files_to_register.get());
-
- GetContentClient()->browser()->AppendMappedFileCommandLineSwitches(cmd_line);
-
if (use_zygote) {
base::ProcessHandle handle = ZygoteHostImpl::GetInstance()->ForkRequest(
cmd_line->argv(), files_to_register.Pass(), process_type);

Powered by Google App Engine
This is Rietveld 408576698