refactor: return-braced-init-list pt 2 of 2 (#44891)
* refactor: more return-braced-init-list, this time for v8 and gin objects Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: more return-braced-init-list, this time for v8, gin, std, and base objects 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:
parent
dc0c6c6f3f
commit
c63613f290
35 changed files with 64 additions and 64 deletions
|
@ -188,7 +188,7 @@ gin::Handle<DataPipeHolder> DataPipeHolder::From(v8::Isolate* isolate,
|
|||
if (gin::ConvertFromV8(isolate, object.ToLocalChecked(), &handle))
|
||||
return handle;
|
||||
}
|
||||
return gin::Handle<DataPipeHolder>();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace electron::api
|
||||
|
|
|
@ -209,7 +209,7 @@ const GURL& DownloadItem::GetURL() const {
|
|||
|
||||
v8::Local<v8::Value> DownloadItem::GetURLChain() const {
|
||||
if (!CheckAlive())
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
return gin::ConvertToV8(isolate_, download_item_->GetUrlChain());
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ gin::Handle<Notification> Notification::New(gin_helper::ErrorThrower thrower,
|
|||
gin::Arguments* args) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
thrower.ThrowError("Cannot create Notification before app is ready");
|
||||
return gin::Handle<Notification>();
|
||||
return {};
|
||||
}
|
||||
return gin::CreateHandle(thrower.isolate(), new Notification(args));
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ gin::Handle<Protocol> Protocol::Create(
|
|||
// static
|
||||
gin::Handle<Protocol> Protocol::New(gin_helper::ErrorThrower thrower) {
|
||||
thrower.ThrowError("Protocol cannot be created from JS");
|
||||
return gin::Handle<Protocol>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -132,7 +132,7 @@ v8::Local<v8::Value> ServiceWorkerContext::GetWorkerInfoFromID(
|
|||
auto iter = info_map.find(version_id);
|
||||
if (iter == info_map.end()) {
|
||||
thrower.ThrowError("Could not find service worker with that version_id");
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
return ServiceWorkerRunningInfoToDict(thrower.isolate(),
|
||||
std::move(iter->second));
|
||||
|
|
|
@ -1583,7 +1583,7 @@ std::optional<gin::Handle<Session>> Session::FromPath(
|
|||
gin::Handle<Session> Session::New() {
|
||||
gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate())
|
||||
.ThrowError("Session objects cannot be created with 'new'");
|
||||
return gin::Handle<Session>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Session::FillObjectTemplate(v8::Isolate* isolate,
|
||||
|
|
|
@ -154,7 +154,7 @@ std::string SystemPreferences::GetMediaAccessStatus(
|
|||
DeviceAccessStatus::DeviceAccessStatus_Allowed);
|
||||
} else {
|
||||
thrower.ThrowError("Invalid media type");
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
|
|||
gin_helper::Dictionary dict;
|
||||
if (!args->GetNext(&dict)) {
|
||||
args->ThrowTypeError("Options must be an object.");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::u16string display_name;
|
||||
|
@ -429,19 +429,19 @@ gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
|
|||
dict.Get("modulePath", ¶ms->script);
|
||||
if (dict.Has("args") && !dict.Get("args", ¶ms->args)) {
|
||||
args->ThrowTypeError("Invalid value for args");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
gin_helper::Dictionary opts;
|
||||
if (dict.Get("options", &opts)) {
|
||||
if (opts.Has("env") && !opts.Get("env", &env_map)) {
|
||||
args->ThrowTypeError("Invalid value for env");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (opts.Has("execArgv") && !opts.Get("execArgv", ¶ms->exec_args)) {
|
||||
args->ThrowTypeError("Invalid value for execArgv");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
opts.Get("serviceName", &display_name);
|
||||
|
|
|
@ -429,7 +429,7 @@ gin::Handle<View> View::Create(v8::Isolate* isolate) {
|
|||
if (gin::ConvertFromV8(isolate, obj, &view))
|
||||
return view;
|
||||
}
|
||||
return gin::Handle<View>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -1984,7 +1984,7 @@ gin::Handle<gin_helper::internal::Event> WebContents::MakeEventWithSender(
|
|||
ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("WebContents was destroyed");
|
||||
}
|
||||
return gin::Handle<gin_helper::internal::Event>();
|
||||
return {};
|
||||
}
|
||||
gin::Handle<gin_helper::internal::Event> event =
|
||||
gin_helper::internal::Event::New(isolate);
|
||||
|
@ -2542,7 +2542,7 @@ std::vector<content::NavigationEntry*> WebContents::GetHistory() const {
|
|||
// If the history is empty, it contains only one entry and that is
|
||||
// "InitialEntry"
|
||||
if (history_length == 1 && controller.GetEntryAtIndex(0)->IsInitialEntry())
|
||||
return std::vector<content::NavigationEntry*>();
|
||||
return {};
|
||||
|
||||
std::vector<content::NavigationEntry*> history;
|
||||
history.reserve(history_length);
|
||||
|
|
|
@ -66,7 +66,7 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
|
|||
if (api_web_contents_)
|
||||
return gin::CreateHandle(isolate, api_web_contents_.get());
|
||||
else
|
||||
return gin::Handle<WebContents>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void WebContentsView::SetBackgroundColor(std::optional<WrappedSkColor> color) {
|
||||
|
@ -152,7 +152,7 @@ gin::Handle<WebContentsView> WebContentsView::Create(
|
|||
if (gin::ConvertFromV8(isolate, web_contents_view_obj, &web_contents_view))
|
||||
return web_contents_view;
|
||||
}
|
||||
return gin::Handle<WebContentsView>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -435,14 +435,14 @@ void WebFrameMain::DOMContentLoaded() {
|
|||
|
||||
// static
|
||||
gin::Handle<WebFrameMain> WebFrameMain::New(v8::Isolate* isolate) {
|
||||
return gin::Handle<WebFrameMain>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate,
|
||||
content::RenderFrameHost* rfh) {
|
||||
if (!rfh)
|
||||
return gin::Handle<WebFrameMain>();
|
||||
return {};
|
||||
|
||||
auto* web_frame = FromRenderFrameHost(rfh);
|
||||
if (web_frame)
|
||||
|
|
|
@ -723,11 +723,11 @@ gin::Handle<WebRequest> WebRequest::From(
|
|||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context) {
|
||||
if (!browser_context)
|
||||
return gin::Handle<WebRequest>();
|
||||
return {};
|
||||
auto* user_data =
|
||||
static_cast<UserData*>(browser_context->GetUserData(kUserDataKey));
|
||||
if (!user_data)
|
||||
return gin::Handle<WebRequest>();
|
||||
return {};
|
||||
return gin::CreateHandle(isolate, user_data->data.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
|||
const std::vector<gin::Handle<MessagePort>>& ports,
|
||||
bool* threw_exception) {
|
||||
if (ports.empty())
|
||||
return std::vector<blink::MessagePortChannel>();
|
||||
return {};
|
||||
|
||||
std::unordered_set<MessagePort*> visited;
|
||||
|
||||
|
@ -244,7 +244,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
|||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Port at index " + base::NumberToString(i) + " is " + type + ".");
|
||||
*threw_exception = true;
|
||||
return std::vector<blink::MessagePortChannel>();
|
||||
return {};
|
||||
}
|
||||
visited.insert(port);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue