Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
refactor: use associated v8::Context for event setup (electron#37355)
Browse files Browse the repository at this point in the history
refactor: use associated v8::Context for event setup
  • Loading branch information
codebytere committed Feb 22, 2023
1 parent 32c60b2 commit 6395898
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shell/browser/electron_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {

v8::HandleScope scope(js_env_->isolate());

node_bindings_->Initialize();
node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());
// Create the global environment.
node::Environment* env = node_bindings_->CreateEnvironment(
js_env_->isolate()->GetCurrentContext(), js_env_->platform());
Expand Down
5 changes: 2 additions & 3 deletions shell/common/node_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void NodeBindings::SetNodeCliFlags() {
}
}

void NodeBindings::Initialize() {
void NodeBindings::Initialize(v8::Local<v8::Context> context) {
TRACE_EVENT0("electron", "NodeBindings::Initialize");
// Open node's error reporting system for browser process.

Expand Down Expand Up @@ -463,8 +463,7 @@ void NodeBindings::Initialize() {
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
#endif

v8::Isolate* isolate = v8::Isolate::GetCurrent();
gin_helper::internal::Event::GetConstructor(isolate->GetCurrentContext());
gin_helper::internal::Event::GetConstructor(context);

g_is_initialized = true;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/common/node_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class NodeBindings {
virtual ~NodeBindings();

// Setup V8, libuv.
void Initialize();
void Initialize(v8::Local<v8::Context> context);

void SetNodeCliFlags();

Expand Down
2 changes: 1 addition & 1 deletion shell/renderer/electron_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ElectronRendererClient::DidCreateScriptContext(

if (!node_integration_initialized_) {
node_integration_initialized_ = true;
node_bindings_->Initialize();
node_bindings_->Initialize(renderer_context);
node_bindings_->PrepareEmbedThread();
}

Expand Down
2 changes: 1 addition & 1 deletion shell/services/node/node_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) {

v8::HandleScope scope(js_env_->isolate());

node_bindings_->Initialize();
node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext());

// Append program path for process.argv0
auto program = base::CommandLine::ForCurrentProcess()->GetProgram();
Expand Down

0 comments on commit 6395898

Please sign in to comment.