From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 20 Sep 2018 17:47:44 -0700
Subject: gin_enable_disable_v8_platform.patch

We don't use gin to create the V8 platform, because we need to inject Node
things.

diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index 646647b6e257ecc5ff0934fe8204db74651c1510..15904644aa5451c6cb0fc2a46a67678824cd0bec 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -162,11 +162,13 @@ void IsolateHolder::Initialize(ScriptMode mode,
                                std::string js_command_line_flags,
                                bool disallow_v8_feature_flag_overrides,
                                v8::FatalErrorCallback fatal_error_callback,
-                               v8::OOMErrorCallback oom_error_callback) {
+                               v8::OOMErrorCallback oom_error_callback,
+                               bool create_v8_platform) {
   CHECK(allocator);
   V8Initializer::Initialize(mode, js_command_line_flags,
                             disallow_v8_feature_flag_overrides,
-                            oom_error_callback);
+                            oom_error_callback,
+                            create_v8_platform);
   g_array_buffer_allocator = allocator;
   g_reference_table = reference_table;
   g_fatal_error_callback = fatal_error_callback;
diff --git a/gin/public/isolate_holder.h b/gin/public/isolate_holder.h
index 3909e70dc1425c2cb02624f4b3017784a2ae6c9d..a57b92f02085d6392e6d9d0cc037df6b972f3c31 100644
--- a/gin/public/isolate_holder.h
+++ b/gin/public/isolate_holder.h
@@ -120,7 +120,8 @@ class GIN_EXPORT IsolateHolder {
                          std::string js_command_line_flags = {},
                          bool disallow_v8_feature_flag_overrides = false,
                          v8::FatalErrorCallback fatal_error_callback = nullptr,
-                         v8::OOMErrorCallback oom_error_callback = nullptr);
+                         v8::OOMErrorCallback oom_error_callback = nullptr,
+                         bool create_v8_platform = true);
 
   // Returns whether `Initialize` has already been invoked in the process.
   // Initialization is a one-way operation (i.e., this method cannot return
diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc
index c92630276ca0319341eb636b00ccdf7ef6fd0c0f..4127979946a373d4e1e1589c618518575016ed8c 100644
--- a/gin/v8_initializer.cc
+++ b/gin/v8_initializer.cc
@@ -525,7 +525,8 @@ void SetFeatureFlags() {
 void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
                                const std::string& js_command_line_flags,
                                bool disallow_v8_feature_flag_overrides,
-                               v8::OOMErrorCallback oom_error_callback) {
+                               v8::OOMErrorCallback oom_error_callback,
+                               bool create_v8_platform) {
   static bool v8_is_initialized = false;
   if (v8_is_initialized)
     return;
@@ -540,7 +541,8 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
   }
   SetFlags(mode, js_command_line_flags);
 
-  v8::V8::InitializePlatform(V8Platform::Get());
+  if (create_v8_platform)
+    v8::V8::InitializePlatform(V8Platform::Get());
 
   // Set this as early as possible in order to ensure OOM errors are reported
   // correctly.
diff --git a/gin/v8_initializer.h b/gin/v8_initializer.h
index 1341b77198431e1c426bff043bdb2bbcf202c8ca..ec64afd9dd91b292604ca834a91b9cfbd52eb853 100644
--- a/gin/v8_initializer.h
+++ b/gin/v8_initializer.h
@@ -32,7 +32,8 @@ class GIN_EXPORT V8Initializer {
   static void Initialize(IsolateHolder::ScriptMode mode,
                          const std::string& js_command_line_flags,
                          bool disallow_v8_feature_flag_overrides,
-                         v8::OOMErrorCallback oom_error_callback);
+                         v8::OOMErrorCallback oom_error_callback,
+                         bool create_v8_platform = true);
 
   // Get address and size information for currently loaded snapshot.
   // If no snapshot is loaded, the return values are null for addresses
