refactor: avoid deprecated v8::Context::GetIsolate() calls (pt 1) (#47760)

* refactor: avoid redundant GetIsolate() calls in NodeBindings::CreateEnvironment()

Xref: https://chromium-review.googlesource.com/c/v8/v8/+/6563615

* refactor: use v8::Isolate::GetCurrent() in Initialize() methods

* refactor: add v8::Isolate* arg to NodeBindings::CreateEnvironment()

* fixup! refactor: use v8::Isolate::GetCurrent() in Initialize() methods

* refactor: add v8::Isolate* arg to RendererClientBase::DidCreateScriptContext()

* fixup! refactor: add v8::Isolate* arg to NodeBindings::CreateEnvironment()

* fixup! fixup! refactor: use v8::Isolate::GetCurrent() in Initialize() methods

refactor: prefer JavascriptEnvironment::GetIsolate() in the browser layer
This commit is contained in:
Charles Kerr
2025-07-21 09:34:38 -05:00
committed by GitHub
parent 2f4a070c39
commit 39cca586f6
61 changed files with 136 additions and 110 deletions

View File

@@ -1106,8 +1106,8 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
gin_helper::Dictionary dict(isolate, exports);
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict{isolate, exports};
dict.SetMethod("executeInWorld", &electron::api::ExecuteInWorld);
dict.SetMethod("exposeAPIInWorld", &electron::api::ExposeAPIInWorld);
dict.SetMethod("_overrideGlobalValueFromIsolatedWorld",

View File

@@ -29,7 +29,8 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
gin_helper::Dictionary dict(context->GetIsolate(), exports);
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict{isolate, exports};
#if IS_MAS_BUILD()
dict.SetMethod("addExtraParameter", &SetCrashKeyStub);
dict.SetMethod("removeExtraParameter", &ClearCrashKeyStub);

View File

@@ -267,7 +267,8 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
gin_helper::Dictionary dict(context->GetIsolate(), exports);
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict{isolate, exports};
dict.SetMethod("createForRenderFrame", &IPCRenderFrame::Create);
dict.SetMethod("createForServiceWorker", &IPCServiceWorker::Create);
}

View File

@@ -963,8 +963,8 @@ void Initialize(v8::Local<v8::Object> exports,
void* priv) {
using namespace electron::api; // NOLINT(build/namespaces)
v8::Isolate* isolate = context->GetIsolate();
gin_helper::Dictionary dict(isolate, exports);
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict{isolate, exports};
dict.Set("mainFrame", WebFrameRenderer::Create(
isolate, electron::GetRenderFrame(exports)));
}

View File

@@ -30,8 +30,8 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
gin_helper::Dictionary dict(isolate, exports);
v8::Isolate* const isolate = v8::Isolate::GetCurrent();
gin_helper::Dictionary dict{isolate, exports};
dict.SetMethod("getPathForFile", &electron::api::web_utils::GetPathForFile);
}