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

Unified Diff: content/app/content_main_runner.cc

Issue 2687683006: Don't initialize V8 in the GPU process. (Closed)
Patch Set: Fix compilation on Android and Win. Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/app/content_main_runner.cc
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 934bac48a0bdbf6fff89c24b0d2d8719094f2eca..0cedd5ffc4a3be0b58f631aa2dbacc585b3406d2 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -137,6 +137,14 @@ namespace content {
namespace {
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA) && defined(OS_ANDROID)
+#if defined __LP64__
+#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor64
+#else
+#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor32
+#endif
+#endif
+
// This sets up two singletons responsible for managing field trials. The
// |field_trial_list| singleton lives on the stack and must outlive the Run()
// method of the process.
@@ -170,6 +178,55 @@ void InitializeFieldTrialAndFeatureList(
base::FeatureList::SetInstance(std::move(feature_list));
}
+void InitializeV8IfNeeded(
+ const base::CommandLine& command_line,
+ const std::string& process_type) {
+ if (process_type == switches::kGpuProcess)
+ return;
+
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+ base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance();
+#if !defined(OS_ANDROID)
+ // kV8NativesDataDescriptor and kV8SnapshotDataDescriptor could be shared
+ // with child processes via file descriptors. On Android they are set in
+ // ChildProcessService::InternalInitChildProcess, otherwise set them here.
+ if (command_line.HasSwitch(switches::kV8NativesPassedByFD)) {
+ g_fds->Set(
+ kV8NativesDataDescriptor,
+ kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+ }
+ if (command_line.HasSwitch(switches::kV8SnapshotPassedByFD)) {
+ g_fds->Set(
+ kV8SnapshotDataDescriptor,
+ kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+ }
+#endif // !OS_ANDROID
+ int v8_natives_fd = g_fds->MaybeGet(kV8NativesDataDescriptor);
+ int v8_snapshot_fd = g_fds->MaybeGet(kV8SnapshotDataDescriptor);
+ if (v8_snapshot_fd != -1) {
+ auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor);
+ gin::V8Initializer::LoadV8SnapshotFromFD(
+ v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size);
+ } else {
+ gin::V8Initializer::LoadV8Snapshot();
+ }
+ if (v8_natives_fd != -1) {
+ auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor);
+ gin::V8Initializer::LoadV8NativesFromFD(
+ v8_natives_fd, v8_natives_region.offset, v8_natives_region.size);
+ } else {
+ gin::V8Initializer::LoadV8Natives();
+ }
+#else
+#if !defined(CHROME_MULTIPLE_DLL_BROWSER)
+ gin::V8Initializer::LoadV8Snapshot();
+ gin::V8Initializer::LoadV8Natives();
+#endif // !CHROME_MULTIPLE_DLL_BROWSER
+#endif // OS_POSIX && !OS_MACOSX
+#endif // V8_USE_EXTERNAL_STARTUP_DATA
+}
+
} // namespace
#if !defined(CHROME_MULTIPLE_DLL_CHILD)
@@ -186,14 +243,6 @@ base::LazyInstance<ContentUtilityClient>
g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER;
#endif // !CHROME_MULTIPLE_DLL_BROWSER
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA) && defined(OS_ANDROID)
-#if defined __LP64__
-#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor64
-#else
-#define kV8SnapshotDataDescriptor kV8SnapshotDataDescriptor32
-#endif
-#endif
-
#if defined(OS_POSIX)
// Setup signal-handling state: resanitize most signals, ignore SIGPIPE.
@@ -707,46 +756,7 @@ class ContentMainRunnerImpl : public ContentMainRunner {
base::StatisticsRecorder::Initialize();
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
-#if !defined(OS_ANDROID)
- // kV8NativesDataDescriptor and kV8SnapshotDataDescriptor could be shared
- // with child processes via file descriptors. On Android they are set in
- // ChildProcessService::InternalInitChildProcess, otherwise set them here.
- if (command_line.HasSwitch(switches::kV8NativesPassedByFD)) {
- g_fds->Set(
- kV8NativesDataDescriptor,
- kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
- }
- if (command_line.HasSwitch(switches::kV8SnapshotPassedByFD)) {
- g_fds->Set(
- kV8SnapshotDataDescriptor,
- kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
- }
-#endif // !OS_ANDROID
- int v8_natives_fd = g_fds->MaybeGet(kV8NativesDataDescriptor);
- int v8_snapshot_fd = g_fds->MaybeGet(kV8SnapshotDataDescriptor);
- if (v8_snapshot_fd != -1) {
- auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor);
- gin::V8Initializer::LoadV8SnapshotFromFD(
- v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size);
- } else {
- gin::V8Initializer::LoadV8Snapshot();
- }
- if (v8_natives_fd != -1) {
- auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor);
- gin::V8Initializer::LoadV8NativesFromFD(
- v8_natives_fd, v8_natives_region.offset, v8_natives_region.size);
- } else {
- gin::V8Initializer::LoadV8Natives();
- }
-#else
-#if !defined(CHROME_MULTIPLE_DLL_BROWSER)
- gin::V8Initializer::LoadV8Snapshot();
- gin::V8Initializer::LoadV8Natives();
-#endif // !CHROME_MULTIPLE_DLL_BROWSER
-#endif // OS_POSIX && !OS_MACOSX
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
+ InitializeV8IfNeeded(command_line, process_type);
#if !defined(OFFICIAL_BUILD)
#if defined(OS_WIN)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698