chore: rename built-in modules to bindings to match naming update in node (#37182)

This commit is contained in:
Milan Burda 2023-02-09 02:31:38 +01:00 committed by GitHub
parent 8b380ee2f2
commit 35a9e67dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 103 additions and 100 deletions

View file

@ -138,7 +138,7 @@ interface Process {
At the very bottom of your `api_name.cc` file: At the very bottom of your `api_name.cc` file:
```cpp title='api_name.cc' ```cpp title='api_name.cc'
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_{api_name},Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_{api_name},Initialize)
``` ```
In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/blob/main/shell/common/node_bindings.cc) file, add your node binding name to Electron's built-in modules. In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/blob/main/shell/common/node_bindings.cc) file, add your node binding name to Electron's built-in modules.

View file

@ -146,8 +146,8 @@ int NodeMain(int argc, char* argv[]) {
feature_list->InitializeFromCommandLine("", ""); feature_list->InitializeFromCommandLine("", "");
base::FeatureList::SetInstance(std::move(feature_list)); base::FeatureList::SetInstance(std::move(feature_list));
// Explicitly register electron's builtin modules. // Explicitly register electron's builtin bindings.
NodeBindings::RegisterBuiltinModules(); NodeBindings::RegisterBuiltinBindings();
// Parse and set Node.js cli flags. // Parse and set Node.js cli flags.
int flags_exit_code = SetNodeCliFlags(); int flags_exit_code = SetNodeCliFlags();

View file

@ -1865,4 +1865,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_app, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_app, Initialize)

View file

@ -149,4 +149,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_auto_updater, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_auto_updater, Initialize)

View file

@ -1359,4 +1359,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_base_window, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_base_window, Initialize)

View file

@ -221,4 +221,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_browser_view, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_browser_view, Initialize)

View file

@ -488,4 +488,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_window, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_window, Initialize)

View file

@ -178,4 +178,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_content_tracing, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_content_tracing, Initialize)

View file

@ -279,4 +279,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_crash_reporter, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_crash_reporter, Initialize)

View file

@ -356,4 +356,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_desktop_capturer, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_desktop_capturer, Initialize)

View file

@ -105,4 +105,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_dialog, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_dialog, Initialize)

View file

@ -25,4 +25,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_event, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_event, Initialize)

View file

@ -46,4 +46,4 @@ v8::Local<v8::Object> GetEventEmitterPrototype(v8::Isolate* isolate) {
} // namespace electron } // namespace electron
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_event_emitter, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_event_emitter, Initialize)

View file

@ -195,4 +195,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_global_shortcut, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_global_shortcut, Initialize)

View file

@ -230,4 +230,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_in_app_purchase, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_in_app_purchase, Initialize)

View file

@ -321,4 +321,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_menu, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_menu, Initialize)

View file

@ -170,4 +170,4 @@ bool Converter<ui::NativeTheme::ThemeSource>::FromV8(
} // namespace gin } // namespace gin
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_native_theme, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_native_theme, Initialize)

View file

@ -58,4 +58,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_net, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_net, Initialize)

View file

@ -299,4 +299,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_notification, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_notification, Initialize)

View file

@ -154,4 +154,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_power_monitor, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_power_monitor, Initialize)

View file

@ -139,5 +139,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_power_save_blocker, NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_power_save_blocker,
Initialize) Initialize)

View file

@ -111,4 +111,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_printing, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_printing, Initialize)

View file

@ -339,4 +339,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_protocol, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_protocol, Initialize)

View file

@ -73,5 +73,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_push_notifications, NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_push_notifications,
Initialize) Initialize)

View file

@ -131,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("decryptString", &electron::safestorage::DecryptString); dict.SetMethod("decryptString", &electron::safestorage::DecryptString);
} }
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_safe_storage, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_safe_storage, Initialize)

View file

@ -196,4 +196,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_screen, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_screen, Initialize)

View file

@ -1313,4 +1313,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_session, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_session, Initialize)

View file

@ -132,5 +132,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_system_preferences, NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_system_preferences,
Initialize) Initialize)

View file

@ -436,4 +436,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_tray, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_tray, Initialize)

View file

@ -417,4 +417,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_utility_process, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_utility_process, Initialize)

View file

@ -76,4 +76,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_view, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_view, Initialize)

View file

@ -4244,4 +4244,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_contents, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_contents, Initialize)

View file

@ -131,4 +131,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_contents_view, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_contents_view,
Initialize)

View file

@ -459,4 +459,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_frame_main, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_frame_main, Initialize)

View file

@ -47,4 +47,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_view_manager, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_view_manager, Initialize)

View file

@ -293,4 +293,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_message_port, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_message_port, Initialize)

View file

@ -56,4 +56,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_image_view, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_image_view, Initialize)

View file

@ -36,4 +36,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_crashpad_support, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_crashpad_support, Initialize)

View file

@ -246,4 +246,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_asar, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_asar, Initialize)

View file

@ -291,4 +291,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_clipboard, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_clipboard, Initialize)

View file

@ -67,4 +67,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_command_line, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_command_line, Initialize)

View file

@ -42,4 +42,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_environment, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_environment, Initialize)

View file

@ -641,4 +641,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_native_image, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_native_image, Initialize)

View file

@ -186,4 +186,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_shell, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_shell, Initialize)

View file

@ -44,5 +44,5 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_testing, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_testing, Initialize)
#endif #endif

View file

@ -138,4 +138,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_v8_util, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_v8_util, Initialize)

View file

@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_features, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_features, Initialize)

View file

@ -43,7 +43,7 @@
#include "shell/common/crash_keys.h" #include "shell/common/crash_keys.h"
#endif #endif
#define ELECTRON_BROWSER_MODULES(V) \ #define ELECTRON_BROWSER_BINDINGS(V) \
V(electron_browser_app) \ V(electron_browser_app) \
V(electron_browser_auto_updater) \ V(electron_browser_auto_updater) \
V(electron_browser_browser_view) \ V(electron_browser_browser_view) \
@ -78,7 +78,7 @@
V(electron_browser_web_view_manager) \ V(electron_browser_web_view_manager) \
V(electron_browser_window) V(electron_browser_window)
#define ELECTRON_COMMON_MODULES(V) \ #define ELECTRON_COMMON_BINDINGS(V) \
V(electron_common_asar) \ V(electron_common_asar) \
V(electron_common_clipboard) \ V(electron_common_clipboard) \
V(electron_common_command_line) \ V(electron_common_command_line) \
@ -89,38 +89,39 @@
V(electron_common_shell) \ V(electron_common_shell) \
V(electron_common_v8_util) V(electron_common_v8_util)
#define ELECTRON_RENDERER_MODULES(V) \ #define ELECTRON_RENDERER_BINDINGS(V) \
V(electron_renderer_context_bridge) \ V(electron_renderer_context_bridge) \
V(electron_renderer_crash_reporter) \ V(electron_renderer_crash_reporter) \
V(electron_renderer_ipc) \ V(electron_renderer_ipc) \
V(electron_renderer_web_frame) V(electron_renderer_web_frame)
#define ELECTRON_UTILITY_MODULES(V) V(electron_utility_parent_port) #define ELECTRON_UTILITY_BINDINGS(V) V(electron_utility_parent_port)
#define ELECTRON_VIEWS_MODULES(V) V(electron_browser_image_view) #define ELECTRON_VIEWS_BINDINGS(V) V(electron_browser_image_view)
#define ELECTRON_DESKTOP_CAPTURER_MODULE(V) V(electron_browser_desktop_capturer) #define ELECTRON_DESKTOP_CAPTURER_BINDINGS(V) \
V(electron_browser_desktop_capturer)
#define ELECTRON_TESTING_MODULE(V) V(electron_common_testing) #define ELECTRON_TESTING_BINDINGS(V) V(electron_common_testing)
// This is used to load built-in modules. Instead of using // This is used to load built-in bindings. Instead of using
// __attribute__((constructor)), we call the _register_<modname> // __attribute__((constructor)), we call the _register_<modname>
// function for each built-in modules explicitly. This is only // function for each built-in bindings explicitly. This is only
// forward declaration. The definitions are in each module's // forward declaration. The definitions are in each binding's
// implementation when calling the NODE_LINKED_MODULE_CONTEXT_AWARE. // implementation when calling the NODE_LINKED_BINDING_CONTEXT_AWARE.
#define V(modname) void _register_##modname(); #define V(modname) void _register_##modname();
ELECTRON_BROWSER_MODULES(V) ELECTRON_BROWSER_BINDINGS(V)
ELECTRON_COMMON_MODULES(V) ELECTRON_COMMON_BINDINGS(V)
ELECTRON_RENDERER_MODULES(V) ELECTRON_RENDERER_BINDINGS(V)
ELECTRON_UTILITY_MODULES(V) ELECTRON_UTILITY_BINDINGS(V)
#if BUILDFLAG(ENABLE_VIEWS_API) #if BUILDFLAG(ENABLE_VIEWS_API)
ELECTRON_VIEWS_MODULES(V) ELECTRON_VIEWS_BINDINGS(V)
#endif #endif
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER) #if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
ELECTRON_DESKTOP_CAPTURER_MODULE(V) ELECTRON_DESKTOP_CAPTURER_BINDINGS(V)
#endif #endif
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
ELECTRON_TESTING_MODULE(V) ELECTRON_TESTING_BINDINGS(V)
#endif #endif
#undef V #undef V
@ -336,29 +337,29 @@ NodeBindings::~NodeBindings() {
stop_and_close_uv_loop(uv_loop_); stop_and_close_uv_loop(uv_loop_);
} }
void NodeBindings::RegisterBuiltinModules() { void NodeBindings::RegisterBuiltinBindings() {
#define V(modname) _register_##modname(); #define V(modname) _register_##modname();
auto* command_line = base::CommandLine::ForCurrentProcess(); auto* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType); command_line->GetSwitchValueASCII(::switches::kProcessType);
if (process_type.empty()) { if (process_type.empty()) {
ELECTRON_BROWSER_MODULES(V) ELECTRON_BROWSER_BINDINGS(V)
#if BUILDFLAG(ENABLE_VIEWS_API) #if BUILDFLAG(ENABLE_VIEWS_API)
ELECTRON_VIEWS_MODULES(V) ELECTRON_VIEWS_BINDINGS(V)
#endif #endif
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER) #if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
ELECTRON_DESKTOP_CAPTURER_MODULE(V) ELECTRON_DESKTOP_CAPTURER_BINDINGS(V)
#endif #endif
} }
ELECTRON_COMMON_MODULES(V) ELECTRON_COMMON_BINDINGS(V)
if (process_type == ::switches::kRendererProcess) { if (process_type == ::switches::kRendererProcess) {
ELECTRON_RENDERER_MODULES(V) ELECTRON_RENDERER_BINDINGS(V)
} }
if (process_type == ::switches::kUtilityProcess) { if (process_type == ::switches::kUtilityProcess) {
ELECTRON_UTILITY_MODULES(V) ELECTRON_UTILITY_BINDINGS(V)
} }
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
ELECTRON_TESTING_MODULE(V) ELECTRON_TESTING_BINDINGS(V)
#endif #endif
#undef V #undef V
} }
@ -424,8 +425,8 @@ void NodeBindings::Initialize() {
ElectronCommandLine::InitializeFromCommandLine(); ElectronCommandLine::InitializeFromCommandLine();
#endif #endif
// Explicitly register electron's builtin modules. // Explicitly register electron's builtin bindings.
RegisterBuiltinModules(); RegisterBuiltinBindings();
// Parse and set Node.js cli flags. // Parse and set Node.js cli flags.
SetNodeCliFlags(); SetNodeCliFlags();

View file

@ -79,7 +79,7 @@ class NodeBindings {
enum class BrowserEnvironment { kBrowser, kRenderer, kUtility, kWorker }; enum class BrowserEnvironment { kBrowser, kRenderer, kUtility, kWorker };
static NodeBindings* Create(BrowserEnvironment browser_env); static NodeBindings* Create(BrowserEnvironment browser_env);
static void RegisterBuiltinModules(); static void RegisterBuiltinBindings();
static bool IsInitialized(); static bool IsInitialized();
virtual ~NodeBindings(); virtual ~NodeBindings();

View file

@ -31,10 +31,10 @@
#include "electron/pop_node_defines.h" #include "electron/pop_node_defines.h"
// Alternative to NODE_MODULE_CONTEXT_AWARE_X. // Alternative to NODE_BINDING_CONTEXT_AWARE_X.
// Allows to explicitly register builtin modules instead of using // Allows to explicitly register builtin bindings instead of using
// __attribute__((constructor)). // __attribute__((constructor)).
#define NODE_LINKED_MODULE_CONTEXT_AWARE(modname, regfunc) \ #define NODE_LINKED_BINDING_CONTEXT_AWARE(modname, regfunc) \
NODE_BINDING_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_LINKED) NODE_BINDING_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_LINKED)
#endif // ELECTRON_SHELL_COMMON_NODE_INCLUDES_H_ #endif // ELECTRON_SHELL_COMMON_NODE_INCLUDES_H_

View file

@ -740,4 +740,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_context_bridge, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_context_bridge, Initialize)

View file

@ -42,4 +42,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_crash_reporter, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_crash_reporter, Initialize)

View file

@ -237,4 +237,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_ipc, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_ipc, Initialize)

View file

@ -916,4 +916,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_web_frame, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_web_frame, Initialize)

View file

@ -36,16 +36,16 @@ namespace electron {
namespace { namespace {
const char kEmitProcessEventKey[] = "emit-process-event"; const char kEmitProcessEventKey[] = "emit-process-event";
const char kModuleCacheKey[] = "native-module-cache"; const char kBindingCacheKey[] = "native-binding-cache";
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) { v8::Local<v8::Object> GetBindingCache(v8::Isolate* isolate) {
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
gin_helper::Dictionary global(isolate, context->Global()); gin_helper::Dictionary global(isolate, context->Global());
v8::Local<v8::Value> cache; v8::Local<v8::Value> cache;
if (!global.GetHidden(kModuleCacheKey, &cache)) { if (!global.GetHidden(kBindingCacheKey, &cache)) {
cache = v8::Object::New(isolate); cache = v8::Object::New(isolate);
global.SetHidden(kModuleCacheKey, cache); global.SetHidden(kBindingCacheKey, cache);
} }
return cache->ToObject(context).ToLocalChecked(); return cache->ToObject(context).ToLocalChecked();
@ -56,18 +56,19 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
v8::Local<v8::String> key, v8::Local<v8::String> key,
gin_helper::Arguments* margs) { gin_helper::Arguments* margs) {
v8::Local<v8::Object> exports; v8::Local<v8::Object> exports;
std::string module_key = gin::V8ToString(isolate, key); std::string binding_key = gin::V8ToString(isolate, key);
gin_helper::Dictionary cache(isolate, GetModuleCache(isolate)); gin_helper::Dictionary cache(isolate, GetBindingCache(isolate));
if (cache.Get(module_key.c_str(), &exports)) { if (cache.Get(binding_key.c_str(), &exports)) {
return exports; return exports;
} }
auto* mod = node::binding::get_linked_module(module_key.c_str()); auto* mod = node::binding::get_linked_module(binding_key.c_str());
if (!mod) { if (!mod) {
char errmsg[1024]; char errmsg[1024];
snprintf(errmsg, sizeof(errmsg), "No such module: %s", module_key.c_str()); snprintf(errmsg, sizeof(errmsg), "No such binding: %s",
binding_key.c_str());
margs->ThrowError(errmsg); margs->ThrowError(errmsg);
return exports; return exports;
} }
@ -77,7 +78,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
DCHECK_NE(mod->nm_context_register_func, nullptr); DCHECK_NE(mod->nm_context_register_func, nullptr);
mod->nm_context_register_func(exports, v8::Null(isolate), mod->nm_context_register_func(exports, v8::Null(isolate),
isolate->GetCurrentContext(), mod->nm_priv); isolate->GetCurrentContext(), mod->nm_priv);
cache.Set(module_key.c_str(), exports); cache.Set(binding_key.c_str(), exports);
return exports; return exports;
} }
@ -120,8 +121,8 @@ void InvokeEmitProcessEvent(v8::Handle<v8::Context> context,
} // namespace } // namespace
ElectronSandboxedRendererClient::ElectronSandboxedRendererClient() { ElectronSandboxedRendererClient::ElectronSandboxedRendererClient() {
// Explicitly register electron's builtin modules. // Explicitly register electron's builtin bindings.
NodeBindings::RegisterBuiltinModules(); NodeBindings::RegisterBuiltinBindings();
metrics_ = base::ProcessMetrics::CreateCurrentProcessMetrics(); metrics_ = base::ProcessMetrics::CreateCurrentProcessMetrics();
} }

View file

@ -130,4 +130,4 @@ void Initialize(v8::Local<v8::Object> exports,
} // namespace } // namespace
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_utility_parent_port, Initialize) NODE_LINKED_BINDING_CONTEXT_AWARE(electron_utility_parent_port, Initialize)