refactor: avoid deprecated v8::Context::GetIsolate() calls (pt 2) (#47896)

* refactor: add a v8::Isolate* arg to Constructible::GetConstructor()

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

* refactor: add a v8::Isolate* arg to NodeBindings::Initialize()

This is needed for the GetConstructor() call

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

* refactor: avoid v8::Context::GetIsolate() call in GetIpcObject() by taking it as an arg

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

* refactor: avoid v8::Context::GetIsolate() call in ipc_native::EmitIPCEvent() by taking it as an arg

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-29 10:34:18 -04:00
committed by GitHub
parent edccb0a7ea
commit e1e12318e2
18 changed files with 42 additions and 36 deletions

View File

@@ -40,8 +40,8 @@ template <typename T>
class Constructible {
public:
static v8::Local<v8::Function> GetConstructor(
v8::Isolate* const isolate,
v8::Local<v8::Context> context) {
v8::Isolate* isolate = context->GetIsolate();
gin::PerIsolateData* data = gin::PerIsolateData::From(isolate);
auto* wrapper_info = &T::kWrapperInfo;
v8::Local<v8::FunctionTemplate> constructor =

View File

@@ -576,7 +576,8 @@ std::vector<std::string> NodeBindings::ParseNodeCliFlags() {
return args;
}
void NodeBindings::Initialize(v8::Local<v8::Context> context) {
void NodeBindings::Initialize(v8::Isolate* const isolate,
v8::Local<v8::Context> context) {
TRACE_EVENT0("electron", "NodeBindings::Initialize");
// Open node's error reporting system for browser process.
@@ -635,7 +636,7 @@ void NodeBindings::Initialize(v8::Local<v8::Context> context) {
SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX);
#endif
gin_helper::internal::Event::GetConstructor(context);
gin_helper::internal::Event::GetConstructor(isolate, context);
g_is_initialized = true;
}

View File

@@ -125,7 +125,7 @@ class NodeBindings {
virtual ~NodeBindings();
// Setup V8, libuv.
void Initialize(v8::Local<v8::Context> context);
void Initialize(v8::Isolate* isolate, v8::Local<v8::Context> context);
std::vector<std::string> ParseNodeCliFlags();