зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619592 - Refactor persistence type checks using new IsValidPersistenceType method; r=dom-workers-and-storage-reviewers,sg
This patch makes use of the IsValidPersistenceType function it adds at places where individual checks were done before. It also moves some checks to the parameter validation phase. Differential Revision: https://phabricator.services.mozilla.com/D66947 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5670c32118
Коммит
5cebbc21b1
|
@ -13489,9 +13489,7 @@ Factory::AllocPBackgroundIDBFactoryRequestParent(
|
|||
MOZ_ASSERT(commonParams);
|
||||
|
||||
const DatabaseMetadata& metadata = commonParams->metadata();
|
||||
if (NS_WARN_IF(metadata.persistenceType() != PERSISTENCE_TYPE_PERSISTENT &&
|
||||
metadata.persistenceType() != PERSISTENCE_TYPE_TEMPORARY &&
|
||||
metadata.persistenceType() != PERSISTENCE_TYPE_DEFAULT)) {
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(metadata.persistenceType()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -27659,9 +27657,7 @@ mozilla::ipc::IPCResult Utils::RecvGetFileReferences(
|
|||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(aPersistenceType != quota::PERSISTENCE_TYPE_PERSISTENT &&
|
||||
aPersistenceType != quota::PERSISTENCE_TYPE_TEMPORARY &&
|
||||
aPersistenceType != quota::PERSISTENCE_TYPE_DEFAULT)) {
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(aPersistenceType))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
|
|
|
@ -8585,6 +8585,11 @@ bool Quota::VerifyRequestParams(const RequestParams& aParams) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(params.persistenceType()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -8598,6 +8603,13 @@ bool Quota::VerifyRequestParams(const RequestParams& aParams) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (params.persistenceTypeIsExplicit()) {
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(params.persistenceType()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -8611,6 +8623,13 @@ bool Quota::VerifyRequestParams(const RequestParams& aParams) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (params.persistenceTypeIsExplicit()) {
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(params.persistenceType()))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -9511,8 +9530,6 @@ void InitStorageAndOriginOp::Init(Quota* aQuota) {
|
|||
|
||||
QuotaRequestBase::Init(aQuota);
|
||||
|
||||
MOZ_ASSERT(mParams.persistenceType() != PERSISTENCE_TYPE_INVALID);
|
||||
|
||||
mPersistenceType.SetValue(mParams.persistenceType());
|
||||
|
||||
if (mParams.clientTypeIsExplicit()) {
|
||||
|
@ -9834,8 +9851,6 @@ void ClearOriginOp::Init(Quota* aQuota) {
|
|||
QuotaRequestBase::Init(aQuota);
|
||||
|
||||
if (mParams.persistenceTypeIsExplicit()) {
|
||||
MOZ_ASSERT(mParams.persistenceType() != PERSISTENCE_TYPE_INVALID);
|
||||
|
||||
mPersistenceType.SetValue(mParams.persistenceType());
|
||||
}
|
||||
|
||||
|
|
|
@ -146,6 +146,18 @@ void BadPersistenceType() { MOZ_CRASH("Bad persistence type value!"); }
|
|||
|
||||
} // namespace
|
||||
|
||||
bool IsValidPersistenceType(const PersistenceType aPersistenceType) {
|
||||
switch (aPersistenceType) {
|
||||
case PERSISTENCE_TYPE_PERSISTENT:
|
||||
case PERSISTENCE_TYPE_TEMPORARY:
|
||||
case PERSISTENCE_TYPE_DEFAULT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nsLiteralCString PersistenceTypeToString(
|
||||
const PersistenceType aPersistenceType) {
|
||||
const auto maybeString = TypeTo_impl<nsLiteralCString>(aPersistenceType);
|
||||
|
|
|
@ -29,6 +29,8 @@ static const PersistenceType kAllPersistenceTypes[] = {
|
|||
PERSISTENCE_TYPE_PERSISTENT, PERSISTENCE_TYPE_TEMPORARY,
|
||||
PERSISTENCE_TYPE_DEFAULT};
|
||||
|
||||
bool IsValidPersistenceType(PersistenceType aPersistenceType);
|
||||
|
||||
nsLiteralCString PersistenceTypeToString(PersistenceType aPersistenceType);
|
||||
|
||||
Maybe<PersistenceType> PersistenceTypeFromString(const nsACString& aString,
|
||||
|
|
|
@ -497,7 +497,7 @@ PBackgroundSDBConnectionParent* AllocPBackgroundSDBConnectionParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(aPersistenceType == PERSISTENCE_TYPE_INVALID)) {
|
||||
if (NS_WARN_IF(!IsValidPersistenceType(aPersistenceType))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче