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

Unified Diff: content/app/content_main_runner.cc

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Work for some comments Created 3 years, 7 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 a677c9d2c6df30e78614b09d396372db33dff781..77efd83eaecbd68adc6a22cf9f31c6fc5aa709e9 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -54,6 +54,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/sandbox_init.h"
+#include "gin/v8_initializer.h"
#include "ipc/ipc_descriptors.h"
#include "media/base/media.h"
#include "ppapi/features/features.h"
@@ -61,11 +62,6 @@
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA) && \
- !defined(CHROME_MULTIPLE_DLL_BROWSER)
-#include "gin/v8_initializer.h"
-#endif
-
#if defined(OS_WIN)
#include <malloc.h>
#include <cstring>
@@ -188,34 +184,50 @@ void InitializeV8IfNeeded(
if (process_type == switches::kGpuProcess)
return;
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
#if defined(OS_POSIX) && !defined(OS_MACOSX)
base::FileDescriptorStore& file_descriptor_store =
base::FileDescriptorStore::GetInstance();
base::MemoryMappedFile::Region region;
+#endif
+
+#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
base::ScopedFD v8_snapshot_fd =
file_descriptor_store.MaybeTakeFD(kV8SnapshotDataDescriptor, &region);
if (v8_snapshot_fd.is_valid()) {
gin::V8Initializer::LoadV8SnapshotFromFD(v8_snapshot_fd.get(),
region.offset, region.size);
- } else {
- gin::V8Initializer::LoadV8Snapshot();
- }
- base::ScopedFD v8_natives_fd =
- file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region);
- if (v8_natives_fd.is_valid()) {
- gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(),
- region.offset, region.size);
- } else {
- gin::V8Initializer::LoadV8Natives();
- }
-#else
-#if !defined(CHROME_MULTIPLE_DLL_BROWSER)
+ } else {
gin::V8Initializer::LoadV8Snapshot();
+ }
+ base::ScopedFD v8_natives_fd =
+ file_descriptor_store.MaybeTakeFD(kV8NativesDataDescriptor, &region);
+ if (v8_natives_fd.is_valid()) {
+ gin::V8Initializer::LoadV8NativesFromFD(v8_natives_fd.get(), region.offset,
+ 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
+
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
haraken 2017/05/20 19:10:01 Does this mean that we don't support the context s
peria 2017/05/30 08:25:43 unfortunately, I'm not sure. This follows the rout
+ base::ScopedFD v8_context_fd =
+ file_descriptor_store.MaybeTakeFD(kV8ContextDataDescriptor, &region);
+ if (v8_context_fd.is_valid()) {
+ gin::V8Initializer::LoadV8ContextFromFD(v8_context_fd.get(), region.offset,
+ region.size);
+ } else {
haraken 2017/05/20 19:10:01 When do we hit this else branch?
peria 2017/05/30 08:25:43 ditto.
+ gin::V8Initializer::LoadV8Context();
+ }
+#elif !defined(CHROME_MULTIPLE_DLL_BROWSER)
+ gin::V8Initializer::LoadV8Context();
+#endif // OS
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698