fix: remove catch-all HandleScope (#22531)
This commit is contained in:
parent
4bca5205bb
commit
19314d3caf
21 changed files with 131 additions and 75 deletions
|
@ -788,8 +788,11 @@ void App::RenderProcessReady(content::RenderProcessHost* host) {
|
|||
// `RenderProcessPreferences`, so this is at least more explicit...
|
||||
content::WebContents* web_contents =
|
||||
ElectronBrowserClient::Get()->GetWebContentsFromProcessID(host->GetID());
|
||||
if (web_contents)
|
||||
WebContents::FromOrCreate(v8::Isolate::GetCurrent(), web_contents);
|
||||
if (web_contents) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
WebContents::FromOrCreate(isolate, web_contents);
|
||||
}
|
||||
}
|
||||
|
||||
void App::RenderProcessDisconnected(base::ProcessId host_pid) {
|
||||
|
|
|
@ -314,6 +314,7 @@ v8::Local<v8::Promise> Cookies::FlushStore() {
|
|||
}
|
||||
|
||||
void Cookies::OnCookieChanged(const net::CookieChangeInfo& change) {
|
||||
v8::HandleScope scope(isolate());
|
||||
Emit("changed", gin::ConvertToV8(isolate(), change.cookie),
|
||||
gin::ConvertToV8(isolate(), change.cause),
|
||||
gin::ConvertToV8(isolate(),
|
||||
|
|
|
@ -214,6 +214,7 @@ void Menu::OnMenuWillClose() {
|
|||
}
|
||||
|
||||
void Menu::OnMenuWillShow() {
|
||||
v8::HandleScope scope(isolate());
|
||||
g_menus[weak_map_id()] = v8::Global<v8::Object>(isolate(), GetWrapper());
|
||||
Emit("menu-will-show");
|
||||
}
|
||||
|
|
|
@ -85,8 +85,10 @@ ServiceWorkerContext::~ServiceWorkerContext() {
|
|||
void ServiceWorkerContext::OnReportConsoleMessage(
|
||||
int64_t version_id,
|
||||
const content::ConsoleMessage& message) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
Emit("console-message",
|
||||
gin::DataObjectBuilder(v8::Isolate::GetCurrent())
|
||||
gin::DataObjectBuilder(isolate)
|
||||
.Set("versionId", version_id)
|
||||
.Set("source", MessageSourceToString(message.source))
|
||||
.Set("level", static_cast<int32_t>(message.message_level))
|
||||
|
|
|
@ -433,6 +433,7 @@ void SimpleURLLoaderWrapper::OnRetry(base::OnceClosure start_retry) {}
|
|||
void SimpleURLLoaderWrapper::OnResponseStarted(
|
||||
const GURL& final_url,
|
||||
const network::mojom::URLResponseHead& response_head) {
|
||||
v8::HandleScope scope(isolate());
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate());
|
||||
dict.Set("statusCode", response_head.headers->response_code());
|
||||
dict.Set("statusMessage", response_head.headers->GetStatusText());
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "gin/data_object_builder.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/common/gin_converters/blink_converter.h"
|
||||
#include "shell/common/gin_converters/std_converter.h"
|
||||
|
||||
namespace gin_helper {
|
||||
|
||||
|
@ -15,7 +17,16 @@ gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin};
|
|||
|
||||
Event::Event() {}
|
||||
|
||||
Event::~Event() = default;
|
||||
Event::~Event() {
|
||||
if (callback_) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
auto message = gin::DataObjectBuilder(isolate)
|
||||
.Set("error", "reply was never sent")
|
||||
.Build();
|
||||
SendReply(isolate, message);
|
||||
}
|
||||
}
|
||||
|
||||
void Event::SetCallback(InvokeCallback callback) {
|
||||
DCHECK(!callback_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue