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

Unified Diff: content/app/content_main_runner.cc

Issue 944913002: Transfer v8 snapshot files as file descriptors to child processes on Posix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tidy up Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/app/content_main_runner.cc
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 3163a4562ce16bcbd69fa98416b432460dcfb3f5..90d661b0f24b99784a40ac55e90852faf1319760 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -53,10 +53,6 @@
#include "gin/public/isolate_holder.h"
#endif
-#if defined(OS_ANDROID)
-#include "content/public/common/content_descriptors.h"
-#endif
-
#if defined(USE_TCMALLOC)
#include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
#if defined(TYPE_PROFILING)
@@ -98,6 +94,7 @@
#include "content/public/common/content_descriptors.h"
#if !defined(OS_MACOSX)
+#include "content/public/common/content_descriptors.h"
#include "content/public/common/zygote_fork_delegate_linux.h"
#endif
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
@@ -519,7 +516,16 @@ class ContentMainRunnerImpl : public ContentMainRunner {
#if defined(OS_LINUX) || defined(OS_OPENBSD)
g_fds->Set(kCrashDumpSignal,
kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor);
-#endif
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+ g_fds->Set(
+ kV8NativesDataDescriptor,
+ kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+ g_fds->Set(
+ kV8SnapshotDataDescriptor,
+ kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+#endif // OS_LINUX || OS_OPENBSD
+
#endif // !OS_WIN
@@ -689,33 +695,29 @@ class ContentMainRunnerImpl : public ContentMainRunner {
} else {
CHECK(base::i18n::InitializeICU());
}
+#else
+ CHECK(base::i18n::InitializeICU());
+#endif // OS_ANDROID
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
- int v8_natives_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
- kV8NativesDataDescriptor);
- int v8_snapshot_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
- kV8SnapshotDataDescriptor);
- if (v8_natives_fd != -1 && v8_snapshot_fd != -1) {
- auto v8_natives_region =
- base::GlobalDescriptors::GetInstance()->GetRegion(
- kV8NativesDataDescriptor);
- auto v8_snapshot_region =
- base::GlobalDescriptors::GetInstance()->GetRegion(
- kV8SnapshotDataDescriptor);
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ if (process_type.empty() || process_type == switches::kZygoteProcess) {
+ // Load snapshot from file for browser or zygote process.
+ CHECK(gin::IsolateHolder::LoadV8Snapshot());
+ } else {
+ base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance();
+ int v8_natives_fd = g_fds->Get(kV8NativesDataDescriptor);
+ int v8_snapshot_fd = g_fds->Get(kV8SnapshotDataDescriptor);
+ auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor);
+ auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor);
CHECK(gin::IsolateHolder::LoadV8SnapshotFd(
v8_natives_fd, v8_natives_region.offset, v8_natives_region.size,
v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size));
- } else {
- CHECK(gin::IsolateHolder::LoadV8Snapshot());
}
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
-
#else
- CHECK(base::i18n::InitializeICU());
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
CHECK(gin::IsolateHolder::LoadV8Snapshot());
+#endif // OS_POSIX
#endif // V8_USE_EXTERNAL_STARTUP_DATA
-#endif // OS_ANDROID
if (delegate_)
delegate_->PreSandboxStartup();

Powered by Google App Engine
This is Rietveld 408576698