mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
refactor: add static ReplyChannel::SendError() helper (#49338)
* refactor: add static void ReplyChannel::SendError() * refactor: use static SendError() instead of instantiating a temporary * refactor: remove non-static version of SendError() * refactor: remove redundant callback-is-non-null checks
This commit is contained in:
@@ -140,31 +140,25 @@ gin_helper::internal::Event* ElectronApiIPCHandlerImpl::MakeIPCEvent(
|
||||
bool internal,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback callback) {
|
||||
if (!session) {
|
||||
if (callback) {
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("Session does not exist");
|
||||
}
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::SendError(isolate, std::move(callback),
|
||||
"Session does not exist");
|
||||
return {};
|
||||
}
|
||||
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (!api_web_contents) {
|
||||
if (callback) {
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("WebContents does not exist");
|
||||
}
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::SendError(isolate, std::move(callback),
|
||||
"WebContents does not exist");
|
||||
return {};
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> wrapper;
|
||||
if (!api_web_contents->GetWrapper(isolate).ToLocal(&wrapper)) {
|
||||
if (callback) {
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("WebContents was destroyed");
|
||||
}
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::SendError(isolate, std::move(callback),
|
||||
"WebContents was destroyed");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -159,11 +159,9 @@ gin_helper::internal::Event* ElectronApiSWIPCHandlerImpl::MakeIPCEvent(
|
||||
bool internal,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback callback) {
|
||||
if (!session) {
|
||||
if (callback) {
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("Session does not exist");
|
||||
}
|
||||
// We must always invoke the callback if present.
|
||||
gin_helper::internal::ReplyChannel::SendError(isolate, std::move(callback),
|
||||
"Session does not exist");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user