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

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

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

Co-authored-by: Charles Kerr <charles@charleskerr.com>

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

refactor: prefer JavascriptEnvironment::GetIsolate() in the browser layer

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-07-21 13:12:24 -04:00 committed by GitHub
commit d426b92326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 136 additions and 110 deletions

View file

@ -13,6 +13,7 @@
#include "base/threading/thread_restrictions.h"
#include "base/trace_event/trace_config.h"
#include "content/public/browser/tracing_controller.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/value_converter.h"
@ -171,7 +172,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 = electron::JavascriptEnvironment::GetIsolate();
gin_helper::Dictionary dict{isolate, exports};
dict.SetMethod("getCategories", &GetCategories);
dict.SetMethod("startRecording", &StartTracing);
dict.SetMethod("stopRecording", &StopRecording);