mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user