Bug 1599801 - NullPrincipal::Init is infallible. r=bzbarsky

I also cleaned up the comment a bit.

Differential Revision: https://phabricator.services.mozilla.com/D54970

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-11-27 20:17:46 +00:00
Родитель b199ff482d
Коммит 817696d634
2 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -54,8 +54,7 @@ already_AddRefed<NullPrincipal> NullPrincipal::CreateWithInheritedAttributes(
already_AddRefed<NullPrincipal> NullPrincipal::CreateWithInheritedAttributes( already_AddRefed<NullPrincipal> NullPrincipal::CreateWithInheritedAttributes(
const OriginAttributes& aOriginAttributes, bool aIsFirstParty) { const OriginAttributes& aOriginAttributes, bool aIsFirstParty) {
RefPtr<NullPrincipal> nullPrin = new NullPrincipal(); RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
nsresult rv = nullPrin->Init(aOriginAttributes, aIsFirstParty); nullPrin->Init(aOriginAttributes, aIsFirstParty);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
return nullPrin.forget(); return nullPrin.forget();
} }
@ -98,8 +97,8 @@ nsresult NullPrincipal::Init(const OriginAttributes& aOriginAttributes,
return NS_OK; return NS_OK;
} }
nsresult NullPrincipal::Init(const OriginAttributes& aOriginAttributes, void NullPrincipal::Init(const OriginAttributes& aOriginAttributes,
bool aIsFirstParty) { bool aIsFirstParty) {
mURI = new NullPrincipalURI(); mURI = new NullPrincipalURI();
nsAutoCString originNoSuffix; nsAutoCString originNoSuffix;
@ -119,8 +118,6 @@ nsresult NullPrincipal::Init(const OriginAttributes& aOriginAttributes,
} }
FinishInit(originNoSuffix, attrs); FinishInit(originNoSuffix, attrs);
return NS_OK;
} }
nsresult NullPrincipal::GetScriptLocation(nsACString& aStr) { nsresult NullPrincipal::GetScriptLocation(nsACString& aStr) {

Просмотреть файл

@ -112,11 +112,11 @@ class NullPrincipal final : public BasePrincipal {
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mURI;
private: private:
// If aIsFirstParty is true, this NullPrincipal will be initialized base on // If aIsFirstParty is true, this NullPrincipal will be initialized based on
// the aOriginAttributes with FirstPartyDomain set to an unique value, and // the aOriginAttributes with FirstPartyDomain set to a unique value.
// this value is generated from mURI.path, with ".mozilla" appending at the // This value is generated from mURI.path, with ".mozilla" appended at the
// end. // end.
nsresult Init(const OriginAttributes& aOriginAttributes, bool aIsFirstParty); void Init(const OriginAttributes& aOriginAttributes, bool aIsFirstParty);
}; };
} // namespace mozilla } // namespace mozilla