refactor: follow upstream's suggestions on when to use EmptyGURL() (#45498)
- Prefer GURL() when we want to return a non-reference empty URL. - In ServiceWorkerMain::GetStorageKey(), use a reference instead of instantiating a new temporary GURL. From url/gurl.h: > // Returns a reference to a singleton empty GURL. This object is for > // callers who return references but don't have anything to return in > // some cases. If you just want an empty URL for normal use, prefer > // GURL().
This commit is contained in:
parent
3db691804b
commit
d7c6fb8250
3 changed files with 4 additions and 4 deletions
|
@ -192,7 +192,7 @@ bool ServiceWorkerMain::IsDestroyed() const {
|
|||
}
|
||||
|
||||
const blink::StorageKey ServiceWorkerMain::GetStorageKey() {
|
||||
GURL scope = version_info_ ? version_info()->scope : GURL::EmptyGURL();
|
||||
const GURL& scope = version_info_ ? version_info()->scope : GURL::EmptyGURL();
|
||||
return blink::StorageKey::CreateFirstParty(url::Origin::Create(scope));
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ int64_t ServiceWorkerMain::VersionID() const {
|
|||
|
||||
GURL ServiceWorkerMain::ScopeURL() const {
|
||||
if (version_destroyed_)
|
||||
return GURL::EmptyGURL();
|
||||
return {};
|
||||
return version_info()->scope;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ int WebFrameMain::RoutingID() const {
|
|||
|
||||
GURL WebFrameMain::URL() const {
|
||||
if (!CheckRenderFrame())
|
||||
return GURL::EmptyGURL();
|
||||
return {};
|
||||
return render_frame_->GetLastCommittedURL();
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ GURL ElectronManagementAPIDelegate::GetEffectiveUpdateURL(
|
|||
const extensions::Extension& extension,
|
||||
content::BrowserContext* context) const {
|
||||
// TODO(codebytere): we do not currently support ExtensionManagement.
|
||||
return GURL::EmptyGURL();
|
||||
return {};
|
||||
}
|
||||
|
||||
void ElectronManagementAPIDelegate::ShowMv2DeprecationReEnableDialog(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue