mirror of https://github.com/electron/electron
77 lines
3.8 KiB
Diff
77 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <marshallofsound@electronjs.org>
|
|
Date: Wed, 8 Mar 2023 13:04:21 -0800
|
|
Subject: refactor: expose HostImportModuleDynamically and
|
|
HostGetImportMetaProperties to embedders
|
|
|
|
This is so that Electron can blend Blink's and Node's implementations of these isolate handlers.
|
|
|
|
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
index 9d7679d1979b21b58ac08723589a48fbff85c9e0..2647b325aefb15721c098d68ef401957e5f14273 100644
|
|
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
|
|
@@ -638,7 +638,9 @@ bool WasmJSPromiseIntegrationEnabledCallback(v8::Local<v8::Context> context) {
|
|
execution_context);
|
|
}
|
|
|
|
-v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
|
+}
|
|
+
|
|
+v8::MaybeLocal<v8::Promise> V8Initializer::HostImportModuleDynamically(
|
|
v8::Local<v8::Context> context,
|
|
v8::Local<v8::Data> v8_host_defined_options,
|
|
v8::Local<v8::Value> v8_referrer_resource_url,
|
|
@@ -716,7 +718,7 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
|
}
|
|
|
|
// https://html.spec.whatwg.org/C/#hostgetimportmetaproperties
|
|
-void HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
+void V8Initializer::HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
v8::Local<v8::Module> module,
|
|
v8::Local<v8::Object> meta) {
|
|
v8::Isolate* isolate = context->GetIsolate();
|
|
@@ -759,9 +761,6 @@ std::ostream& operator<<(std::ostream& os, const PrintV8OOM& oom_details) {
|
|
return os;
|
|
}
|
|
|
|
-} // namespace
|
|
-
|
|
-// static
|
|
void V8Initializer::InitializeV8Common(v8::Isolate* isolate) {
|
|
// Set up garbage collection before setting up anything else as V8 may trigger
|
|
// GCs during Blink setup.
|
|
@@ -781,9 +780,9 @@ void V8Initializer::InitializeV8Common(v8::Isolate* isolate) {
|
|
isolate->SetWasmJSPIEnabledCallback(WasmJSPromiseIntegrationEnabledCallback);
|
|
isolate->SetSharedArrayBufferConstructorEnabledCallback(
|
|
SharedArrayBufferConstructorEnabledCallback);
|
|
- isolate->SetHostImportModuleDynamicallyCallback(HostImportModuleDynamically);
|
|
+ isolate->SetHostImportModuleDynamicallyCallback(V8Initializer::HostImportModuleDynamically);
|
|
isolate->SetHostInitializeImportMetaObjectCallback(
|
|
- HostGetImportMetaProperties);
|
|
+ V8Initializer::HostGetImportMetaProperties);
|
|
isolate->SetMetricsRecorder(std::make_shared<V8MetricsRecorder>(isolate));
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
|
index c3aa714d99a398e29e52c3acb16fc555231d0e4a..6698228c6e76676c6a5cdb39c0d17e2add5547df 100644
|
|
--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
|
+++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h
|
|
@@ -85,6 +85,17 @@ class CORE_EXPORT V8Initializer {
|
|
static void PromiseRejectHandlerInMainThread(v8::PromiseRejectMessage data);
|
|
static void ExceptionPropagationCallback(v8::ExceptionPropagationMessage);
|
|
|
|
+ static v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
|
+ v8::Local<v8::Context> context,
|
|
+ v8::Local<v8::Data> v8_host_defined_options,
|
|
+ v8::Local<v8::Value> v8_referrer_resource_url,
|
|
+ v8::Local<v8::String> v8_specifier,
|
|
+ v8::Local<v8::FixedArray> v8_import_assertions);
|
|
+
|
|
+ static void HostGetImportMetaProperties(v8::Local<v8::Context> context,
|
|
+ v8::Local<v8::Module> module,
|
|
+ v8::Local<v8::Object> meta);
|
|
+
|
|
static void WasmAsyncResolvePromiseCallback(
|
|
v8::Isolate* isolate,
|
|
v8::Local<v8::Context> context,
|