Bug 1709067 - SDB: Remove module specific QM_TRY macros; r=dom-storage-reviewers,jstutte

Depends on D114081

Differential Revision: https://phabricator.services.mozilla.com/D114082
This commit is contained in:
Jan Varga 2021-05-03 19:44:39 +00:00
Родитель 09996cc685
Коммит 0402c4b6e0
2 изменённых файлов: 17 добавлений и 25 удалений

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

@ -1118,11 +1118,11 @@ nsresult OpenOp::Open() {
} else { } else {
MOZ_ASSERT(principalInfo.type() == PrincipalInfo::TContentPrincipalInfo); MOZ_ASSERT(principalInfo.type() == PrincipalInfo::TContentPrincipalInfo);
SDB_TRY_INSPECT(const auto& principal, QM_TRY_INSPECT(const auto& principal,
PrincipalInfoToPrincipal(principalInfo)); PrincipalInfoToPrincipal(principalInfo));
SDB_TRY_UNWRAP(auto principalMetadata, QM_TRY_UNWRAP(auto principalMetadata,
QuotaManager::GetInfoFromPrincipal(principal)); QuotaManager::GetInfoFromPrincipal(principal));
mOriginMetadata = {std::move(principalMetadata), persistenceType}; mOriginMetadata = {std::move(principalMetadata), persistenceType};
} }
@ -1239,20 +1239,20 @@ nsresult OpenOp::DatabaseWork() {
QuotaManager* quotaManager = QuotaManager::Get(); QuotaManager* quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager); MOZ_ASSERT(quotaManager);
SDB_TRY(quotaManager->EnsureStorageIsInitialized()); QM_TRY(quotaManager->EnsureStorageIsInitialized());
SDB_TRY_INSPECT( QM_TRY_INSPECT(
const auto& dbDirectory, const auto& dbDirectory,
([persistenceType = GetConnection()->GetPersistenceType(), &quotaManager, ([persistenceType = GetConnection()->GetPersistenceType(), &quotaManager,
this]() this]()
-> mozilla::Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult> { -> mozilla::Result<std::pair<nsCOMPtr<nsIFile>, bool>, nsresult> {
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT) { if (persistenceType == PERSISTENCE_TYPE_PERSISTENT) {
SDB_TRY_RETURN(quotaManager->EnsurePersistentOriginIsInitialized( QM_TRY_RETURN(quotaManager->EnsurePersistentOriginIsInitialized(
mOriginMetadata)); mOriginMetadata));
} }
SDB_TRY(quotaManager->EnsureTemporaryStorageIsInitialized()); QM_TRY(quotaManager->EnsureTemporaryStorageIsInitialized());
SDB_TRY_RETURN(quotaManager->EnsureTemporaryOriginIsInitialized( QM_TRY_RETURN(quotaManager->EnsureTemporaryOriginIsInitialized(
persistenceType, mOriginMetadata)); persistenceType, mOriginMetadata));
}() }()
.map([](const auto& res) { return res.first; }))); .map([](const auto& res) { return res.first; })));
@ -1731,9 +1731,8 @@ Result<UsageInfo, nsresult> QuotaClient::GetUsageForOrigin(
QuotaManager* quotaManager = QuotaManager::Get(); QuotaManager* quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager); MOZ_ASSERT(quotaManager);
SDB_TRY_UNWRAP(auto directory, QM_TRY_UNWRAP(auto directory, quotaManager->GetDirectoryForOrigin(
quotaManager->GetDirectoryForOrigin(aPersistenceType, aPersistenceType, aOriginMetadata.mOrigin));
aOriginMetadata.mOrigin));
MOZ_ASSERT(directory); MOZ_ASSERT(directory);
@ -1746,12 +1745,12 @@ Result<UsageInfo, nsresult> QuotaClient::GetUsageForOrigin(
DebugOnly<bool> exists; DebugOnly<bool> exists;
MOZ_ASSERT(NS_SUCCEEDED(directory->Exists(&exists)) && exists); MOZ_ASSERT(NS_SUCCEEDED(directory->Exists(&exists)) && exists);
SDB_TRY_RETURN(ReduceEachFileAtomicCancelable( QM_TRY_RETURN(ReduceEachFileAtomicCancelable(
*directory, aCanceled, UsageInfo{}, *directory, aCanceled, UsageInfo{},
[](UsageInfo usageInfo, [](UsageInfo usageInfo,
const nsCOMPtr<nsIFile>& file) -> Result<UsageInfo, nsresult> { const nsCOMPtr<nsIFile>& file) -> Result<UsageInfo, nsresult> {
SDB_TRY_INSPECT(const bool& isDirectory, QM_TRY_INSPECT(const bool& isDirectory,
MOZ_TO_RESULT_INVOKE(file, IsDirectory)); MOZ_TO_RESULT_INVOKE(file, IsDirectory));
if (isDirectory) { if (isDirectory) {
Unused << WARN_IF_FILE_IS_UNKNOWN(*file); Unused << WARN_IF_FILE_IS_UNKNOWN(*file);
@ -1759,11 +1758,11 @@ Result<UsageInfo, nsresult> QuotaClient::GetUsageForOrigin(
} }
nsString leafName; nsString leafName;
SDB_TRY(file->GetLeafName(leafName)); QM_TRY(file->GetLeafName(leafName));
if (StringEndsWith(leafName, kSDBSuffix)) { if (StringEndsWith(leafName, kSDBSuffix)) {
SDB_TRY_INSPECT(const int64_t& fileSize, QM_TRY_INSPECT(const int64_t& fileSize,
MOZ_TO_RESULT_INVOKE(file, GetFileSize)); MOZ_TO_RESULT_INVOKE(file, GetFileSize));
MOZ_ASSERT(fileSize >= 0); MOZ_ASSERT(fileSize >= 0);

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

@ -9,13 +9,6 @@
#include "mozilla/dom/quota/QuotaCommon.h" #include "mozilla/dom/quota/QuotaCommon.h"
// XXX Replace all uses by the QM_* variants and remove these aliases
#define SDB_TRY QM_TRY
#define SDB_TRY_UNWRAP QM_TRY_UNWRAP
#define SDB_TRY_INSPECT QM_TRY_INSPECT
#define SDB_TRY_RETURN QM_TRY_RETURN
#define SDB_FAIL QM_FAIL
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {