mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: avoid deprecated v8::Context::GetIsolate() calls pt 3 context get isolate pt 3 (#47910)
* refactor: add a v8::Isolate* arg to RendererClientBase::IsWebViewFrame() Needed for creating gin dictionaries refactor: add a v8::Isolate* arg to ShouldLoadPreload() Needed for calling IsWebViewFrame() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to electron::util::CompileAndCall() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to OnCreatePreloadableV8Context() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to InvokeEmitProcessEvent() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ServiceWorkerData's constructor Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::SetupMainWorldOverrides() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::WilLReleaseScriptContext() Co-authored-by: Charles Kerr <charles@charleskerr.com> * docs: update docs to avoid v8::Context::GetIsolate() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ElectronSandboxedRendererClient::InitializeBindings() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: avoid v8::Context::GetIsolate() call in PromiseBase::SettleScope::~SettleScope() 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:
@@ -14,15 +14,15 @@
|
||||
namespace gin_helper {
|
||||
|
||||
PromiseBase::SettleScope::SettleScope(const PromiseBase& base)
|
||||
: handle_scope_{base.isolate()},
|
||||
: isolate_{base.isolate()},
|
||||
handle_scope_{isolate_},
|
||||
context_{base.GetContext()},
|
||||
microtasks_scope_(context_, v8::MicrotasksScope::kRunMicrotasks),
|
||||
context_scope_{context_} {}
|
||||
|
||||
PromiseBase::SettleScope::~SettleScope() {
|
||||
if (electron::IsBrowserProcess()) {
|
||||
context_->GetMicrotaskQueue()->PerformCheckpoint(context_->GetIsolate());
|
||||
}
|
||||
if (electron::IsBrowserProcess())
|
||||
context_->GetMicrotaskQueue()->PerformCheckpoint(isolate_);
|
||||
}
|
||||
|
||||
PromiseBase::PromiseBase(v8::Isolate* isolate)
|
||||
|
||||
@@ -59,6 +59,7 @@ class PromiseBase {
|
||||
explicit SettleScope(const PromiseBase& base);
|
||||
~SettleScope();
|
||||
|
||||
const raw_ptr<v8::Isolate> isolate_;
|
||||
v8::HandleScope handle_scope_;
|
||||
v8::Local<v8::Context> context_;
|
||||
v8::MicrotasksScope microtasks_scope_;
|
||||
|
||||
@@ -1007,8 +1007,9 @@ void OnNodePreload(node::Environment* env,
|
||||
env->isolate(), {node::FIXED_ONE_BYTE_STRING(env->isolate(), "process"),
|
||||
node::FIXED_ONE_BYTE_STRING(env->isolate(), "require")});
|
||||
v8::LocalVector<v8::Value> bundle_args(env->isolate(), {process, require});
|
||||
electron::util::CompileAndCall(env->context(), "electron/js2c/node_init",
|
||||
&bundle_params, &bundle_args);
|
||||
electron::util::CompileAndCall(env->isolate(), env->context(),
|
||||
"electron/js2c/node_init", &bundle_params,
|
||||
&bundle_args);
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
namespace electron::util {
|
||||
|
||||
v8::MaybeLocal<v8::Value> CompileAndCall(
|
||||
v8::Isolate* const isolate,
|
||||
v8::Local<v8::Context> context,
|
||||
const char* id,
|
||||
v8::LocalVector<v8::String>* parameters,
|
||||
v8::LocalVector<v8::Value>* arguments) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
v8::TryCatch try_catch(isolate);
|
||||
v8::TryCatch try_catch{isolate};
|
||||
|
||||
thread_local node::builtins::BuiltinLoader builtin_loader;
|
||||
v8::MaybeLocal<v8::Function> compiled = builtin_loader.LookupAndCompile(
|
||||
|
||||
@@ -51,6 +51,7 @@ void EmitDeprecationWarning(std::string_view warning_msg,
|
||||
// JS code run with this method can assume that their top-level
|
||||
// declarations won't affect the global scope.
|
||||
v8::MaybeLocal<v8::Value> CompileAndCall(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Context> context,
|
||||
const char* id,
|
||||
v8::LocalVector<v8::String>* parameters,
|
||||
|
||||
Reference in New Issue
Block a user