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:
trop[bot] 2024-11-30 16:47:30 -06:00 committed by GitHub
parent dc0c6c6f3f
commit c63613f290
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 64 additions and 64 deletions

View file

@ -532,14 +532,14 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
gin_helper::Dictionary opts;
if (!args->GetNext(&opts)) {
args->ThrowTypeError("Expected a dictionary");
return gin::Handle<SimpleURLLoaderWrapper>();
return {};
}
auto request = std::make_unique<network::ResourceRequest>();
opts.Get("method", &request->method);
opts.Get("url", &request->url);
if (!request->url.is_valid()) {
args->ThrowTypeError("Invalid URL");
return gin::Handle<SimpleURLLoaderWrapper>();
return {};
}
request->site_for_cookies = net::SiteForCookies::FromUrl(request->url);
opts.Get("referrer", &request->referrer);
@ -607,7 +607,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
if (!net::HttpUtil::IsValidHeaderName(it.first) ||
!net::HttpUtil::IsValidHeaderValue(it.second)) {
args->ThrowTypeError("Invalid header name or value");
return gin::Handle<SimpleURLLoaderWrapper>();
return {};
}
request->headers.SetHeader(it.first, it.second);
}

View file

@ -49,10 +49,10 @@ v8::Local<v8::Value> GetHiddenValue(v8::Isolate* isolate,
v8::Local<v8::Value> value;
v8::Maybe<bool> result = object->HasPrivate(context, privateKey);
if (!(result.IsJust() && result.FromJust()))
return v8::Local<v8::Value>();
return {};
if (object->GetPrivate(context, privateKey).ToLocal(&value))
return value;
return v8::Local<v8::Value>();
return {};
}
void SetHiddenValue(v8::Isolate* isolate,

View file

@ -49,7 +49,7 @@ base::span<const APIPermissionInfo::InitInfo> GetPermissionInfos() {
return base::make_span(permissions_to_register);
}
base::span<const Alias> GetPermissionAliases() {
return base::span<const Alias>();
return {};
}
} // namespace

View file

@ -64,7 +64,7 @@ v8::Local<v8::Value> CallMethod(v8::Isolate* isolate,
return scope.Escape(CustomEmit(isolate, v8_object, method_name,
std::forward<Args>(args)...));
else
return v8::Local<v8::Value>();
return {};
}
template <typename T, typename... Args>

View file

@ -101,7 +101,7 @@ class TrackableObject : public TrackableObjectBase, public EventEmitter<T> {
if (weak_map_)
return weak_map_->Values(isolate);
else
return std::vector<v8::Local<v8::Object>>();
return {};
}
// Removes this instance from the weak map.

View file

@ -25,7 +25,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
}
if (status != errSecSuccess) {
OSSTATUS_LOG(ERROR, status) << "SecCodeCopyStaticCode";
return std::optional<bool>();
return {};
}
// Copy the signing info from the SecStaticCodeRef.
base::apple::ScopedCFTypeRef<CFDictionaryRef> signing_info;
@ -34,7 +34,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
signing_info.InitializeInto());
if (status != errSecSuccess) {
OSSTATUS_LOG(ERROR, status) << "SecCodeCopySigningInformation";
return std::optional<bool>();
return {};
}
// Look up the code signing flags. If the flags are absent treat this as
// unsigned. This decision is consistent with the StaticCode source:
@ -51,7 +51,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
long long flags;
if (!CFNumberGetValue(signing_info_flags, kCFNumberLongLongType, &flags)) {
LOG(ERROR) << "CFNumberGetValue";
return std::optional<bool>();
return {};
}
if (static_cast<uint32_t>(flags) & kSecCodeSignatureAdhoc) {
return true;

View file

@ -190,7 +190,7 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
v8::Local<v8::FixedArray> v8_import_assertions) {
if (node::Environment::GetCurrent(context) == nullptr) {
if (electron::IsBrowserProcess() || electron::IsUtilityProcess())
return v8::MaybeLocal<v8::Promise>();
return {};
return blink::V8Initializer::HostImportModuleDynamically(
context, v8_host_defined_options, v8_referrer_resource_url,
v8_specifier, v8_import_assertions);