mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1666219 - Renamed QM_TRY_VAR etc. to QM_TRY_UNWRAP etc. r=dom-workers-and-storage-reviewers,ttung,janv
Also change some left-over QM_TRY_VAR uses with const target declarations to QM_TRY_INSPECT et al. Differential Revision: https://phabricator.services.mozilla.com/D90873
This commit is contained in:
parent
bcbf842a92
commit
20a9b720d4
6
dom/cache/CacheCommon.h
vendored
6
dom/cache/CacheCommon.h
vendored
@ -24,13 +24,13 @@
|
||||
#define CACHE_TRY_VAR_GLUE(accessFunction, ...) \
|
||||
QM_TRY_VAR_META(mozilla::dom::cache, MOZ_UNIQUE_VAR(tryResult), \
|
||||
accessFunction, ##__VA_ARGS__)
|
||||
#define CACHE_TRY_VAR(...) CACHE_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define CACHE_TRY_UNWRAP(...) CACHE_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define CACHE_TRY_INSPECT(...) CACHE_TRY_VAR_GLUE(inspect, __VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
# define CACHE_DEBUG_TRY_VAR(...) CACHE_TRY_VAR(__VA_ARGS__)
|
||||
# define CACHE_DEBUG_TRY_UNWRAP(...) CACHE_TRY_UNWRAP(__VA_ARGS__)
|
||||
#else
|
||||
# define CACHE_DEBUG_TRY_VAR(...)
|
||||
# define CACHE_DEBUG_TRY_UNWRAP(...)
|
||||
#endif
|
||||
|
||||
// Cache equivalents of QM_TRY_RETURN and QM_DEBUG_TRY_RETURN.
|
||||
|
65
dom/cache/DBSchema.cpp
vendored
65
dom/cache/DBSchema.cpp
vendored
@ -459,7 +459,7 @@ nsresult CreateOrMigrateSchema(mozIStorageConnection& aConn) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
int32_t schemaVersion;
|
||||
CACHE_TRY_VAR(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
CACHE_TRY_UNWRAP(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
|
||||
if (schemaVersion == kLatestSchemaVersion) {
|
||||
// We already have the correct schema version. Validate it matches
|
||||
@ -548,7 +548,7 @@ nsresult CreateOrMigrateSchema(mozIStorageConnection& aConn) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
CACHE_TRY_VAR(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
CACHE_TRY_UNWRAP(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
}
|
||||
|
||||
nsresult rv = Validate(aConn);
|
||||
@ -694,7 +694,7 @@ Result<DeletionInfo, nsresult> DeleteCacheId(mozIStorageConnection& aConn,
|
||||
// anyway. These body IDs must be deleted one-by-one as content may
|
||||
// still be referencing them invidivually.
|
||||
AutoTArray<EntryId, 256> matches;
|
||||
CACHE_TRY_VAR(matches, QueryAll(aConn, aCacheId));
|
||||
CACHE_TRY_UNWRAP(matches, QueryAll(aConn, aCacheId));
|
||||
|
||||
AutoTArray<nsID, 16> deletedBodyIdList;
|
||||
AutoTArray<IdCount, 16> deletedSecurityIdList;
|
||||
@ -811,7 +811,7 @@ Result<nsTArray<nsID>, nsresult> GetKnownBodyIds(mozIStorageConnection& aConn) {
|
||||
|
||||
if (!isNull) {
|
||||
nsID id;
|
||||
CACHE_TRY_VAR(id, ExtractId(*state, i));
|
||||
CACHE_TRY_UNWRAP(id, ExtractId(*state, i));
|
||||
|
||||
idList.AppendElement(id);
|
||||
}
|
||||
@ -827,14 +827,14 @@ Result<Maybe<SavedResponse>, nsresult> CacheMatch(
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
AutoTArray<EntryId, 1> matches;
|
||||
CACHE_TRY_VAR(matches, QueryCache(aConn, aCacheId, aRequest, aParams, 1));
|
||||
CACHE_TRY_UNWRAP(matches, QueryCache(aConn, aCacheId, aRequest, aParams, 1));
|
||||
|
||||
if (matches.IsEmpty()) {
|
||||
return Maybe<SavedResponse>();
|
||||
}
|
||||
|
||||
SavedResponse response;
|
||||
CACHE_TRY_VAR(response, ReadResponse(aConn, matches[0]));
|
||||
CACHE_TRY_UNWRAP(response, ReadResponse(aConn, matches[0]));
|
||||
|
||||
response.mCacheId = aCacheId;
|
||||
|
||||
@ -848,10 +848,10 @@ Result<nsTArray<SavedResponse>, nsresult> CacheMatchAll(
|
||||
|
||||
AutoTArray<EntryId, 256> matches;
|
||||
if (aMaybeRequest.isNothing()) {
|
||||
CACHE_TRY_VAR(matches, QueryAll(aConn, aCacheId));
|
||||
CACHE_TRY_UNWRAP(matches, QueryAll(aConn, aCacheId));
|
||||
} else {
|
||||
CACHE_TRY_VAR(matches,
|
||||
QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
|
||||
CACHE_TRY_UNWRAP(matches,
|
||||
QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
|
||||
}
|
||||
|
||||
nsTArray<SavedResponse> savedResponses;
|
||||
@ -859,7 +859,7 @@ Result<nsTArray<SavedResponse>, nsresult> CacheMatchAll(
|
||||
// TODO: replace this with a bulk load using SQL IN clause (bug 1110458)
|
||||
for (const auto match : matches) {
|
||||
SavedResponse savedResponse;
|
||||
CACHE_TRY_VAR(savedResponse, ReadResponse(aConn, match));
|
||||
CACHE_TRY_UNWRAP(savedResponse, ReadResponse(aConn, match));
|
||||
|
||||
savedResponse.mCacheId = aCacheId;
|
||||
savedResponses.AppendElement(savedResponse);
|
||||
@ -878,7 +878,7 @@ Result<DeletionInfo, nsresult> CachePut(mozIStorageConnection& aConn,
|
||||
|
||||
CacheQueryParams params(false, false, false, false, u""_ns);
|
||||
AutoTArray<EntryId, 256> matches;
|
||||
CACHE_TRY_VAR(matches, QueryCache(aConn, aCacheId, aRequest, params));
|
||||
CACHE_TRY_UNWRAP(matches, QueryCache(aConn, aCacheId, aRequest, params));
|
||||
|
||||
nsTArray<nsID> deletedBodyIdList;
|
||||
AutoTArray<IdCount, 16> deletedSecurityIdList;
|
||||
@ -911,7 +911,7 @@ Result<Maybe<DeletionInfo>, nsresult> CacheDelete(
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
AutoTArray<EntryId, 256> matches;
|
||||
CACHE_TRY_VAR(matches, QueryCache(aConn, aCacheId, aRequest, aParams));
|
||||
CACHE_TRY_UNWRAP(matches, QueryCache(aConn, aCacheId, aRequest, aParams));
|
||||
|
||||
if (matches.IsEmpty()) {
|
||||
return Maybe<DeletionInfo>();
|
||||
@ -941,17 +941,17 @@ Result<nsTArray<SavedRequest>, nsresult> CacheKeys(
|
||||
|
||||
AutoTArray<EntryId, 256> matches;
|
||||
if (aMaybeRequest.isNothing()) {
|
||||
CACHE_TRY_VAR(matches, QueryAll(aConn, aCacheId));
|
||||
CACHE_TRY_UNWRAP(matches, QueryAll(aConn, aCacheId));
|
||||
} else {
|
||||
CACHE_TRY_VAR(matches,
|
||||
QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
|
||||
CACHE_TRY_UNWRAP(matches,
|
||||
QueryCache(aConn, aCacheId, aMaybeRequest.ref(), aParams));
|
||||
}
|
||||
|
||||
nsTArray<SavedRequest> savedRequests;
|
||||
// TODO: replace this with a bulk load using SQL IN clause (bug 1110458)
|
||||
for (const auto match : matches) {
|
||||
SavedRequest savedRequest;
|
||||
CACHE_TRY_VAR(savedRequest, ReadRequest(aConn, match));
|
||||
CACHE_TRY_UNWRAP(savedRequest, ReadRequest(aConn, match));
|
||||
|
||||
savedRequest.mCacheId = aCacheId;
|
||||
savedRequests.AppendElement(savedRequest);
|
||||
@ -971,8 +971,8 @@ Result<Maybe<SavedResponse>, nsresult> StorageMatch(
|
||||
// and perform the match.
|
||||
if (!aParams.cacheName().EqualsLiteral("")) {
|
||||
Maybe<CacheId> maybeCacheId;
|
||||
CACHE_TRY_VAR(maybeCacheId,
|
||||
StorageGetCacheId(aConn, aNamespace, aParams.cacheName()));
|
||||
CACHE_TRY_UNWRAP(maybeCacheId,
|
||||
StorageGetCacheId(aConn, aNamespace, aParams.cacheName()));
|
||||
if (maybeCacheId.isNothing()) {
|
||||
return Maybe<SavedResponse>();
|
||||
}
|
||||
@ -1011,8 +1011,8 @@ Result<Maybe<SavedResponse>, nsresult> StorageMatch(
|
||||
// Now try to find a match in each cache in order
|
||||
for (const auto cacheId : cacheIdList) {
|
||||
Maybe<SavedResponse> matchedResponse;
|
||||
CACHE_TRY_VAR(matchedResponse,
|
||||
CacheMatch(aConn, cacheId, aRequest, aParams));
|
||||
CACHE_TRY_UNWRAP(matchedResponse,
|
||||
CacheMatch(aConn, cacheId, aRequest, aParams));
|
||||
|
||||
if (matchedResponse.isSome()) {
|
||||
return matchedResponse;
|
||||
@ -1036,7 +1036,7 @@ Result<Maybe<CacheId>, nsresult> StorageGetCacheId(mozIStorageConnection& aConn,
|
||||
"ORDER BY rowid;";
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> state;
|
||||
CACHE_TRY_VAR(state, CreateAndBindKeyStatement(aConn, query, aKey));
|
||||
CACHE_TRY_UNWRAP(state, CreateAndBindKeyStatement(aConn, query, aKey));
|
||||
|
||||
nsresult rv = state->BindInt32ByName("namespace"_ns, aNamespace);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -1108,7 +1108,7 @@ nsresult StorageForgetCache(mozIStorageConnection& aConn, Namespace aNamespace,
|
||||
const char* query = "DELETE FROM storage WHERE namespace=:namespace AND %s;";
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> state;
|
||||
CACHE_TRY_VAR(state, CreateAndBindKeyStatement(aConn, query, aKey));
|
||||
CACHE_TRY_UNWRAP(state, CreateAndBindKeyStatement(aConn, query, aKey));
|
||||
|
||||
nsresult rv = state->BindInt32ByName("namespace"_ns, aNamespace);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -1292,7 +1292,8 @@ Result<nsTArray<EntryId>, nsresult> QueryCache(mozIStorageConnection& aConn,
|
||||
|
||||
if (!aParams.ignoreVary() && varyCount > 0) {
|
||||
bool matchedByVary = false;
|
||||
CACHE_TRY_VAR(matchedByVary, MatchByVaryHeader(aConn, aRequest, entryId));
|
||||
CACHE_TRY_UNWRAP(matchedByVary,
|
||||
MatchByVaryHeader(aConn, aRequest, entryId));
|
||||
if (!matchedByVary) {
|
||||
continue;
|
||||
}
|
||||
@ -1516,7 +1517,7 @@ nsresult DeleteEntries(mozIStorageConnection& aConn,
|
||||
|
||||
if (!isNull) {
|
||||
nsID id;
|
||||
CACHE_TRY_VAR(id, ExtractId(*state, i));
|
||||
CACHE_TRY_UNWRAP(id, ExtractId(*state, i));
|
||||
|
||||
aDeletedBodyIdListOut.AppendElement(id);
|
||||
}
|
||||
@ -1844,9 +1845,9 @@ nsresult InsertEntry(mozIStorageConnection& aConn, CacheId aCacheId,
|
||||
|
||||
int32_t securityId = -1;
|
||||
if (!aResponse.channelInfo().securityInfo().IsEmpty()) {
|
||||
CACHE_TRY_VAR(securityId,
|
||||
InsertSecurityInfo(aConn, *crypto,
|
||||
aResponse.channelInfo().securityInfo()));
|
||||
CACHE_TRY_UNWRAP(
|
||||
securityId, InsertSecurityInfo(aConn, *crypto,
|
||||
aResponse.channelInfo().securityInfo()));
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> state;
|
||||
@ -2265,7 +2266,7 @@ Result<SavedResponse, nsresult> ReadResponse(mozIStorageConnection& aConn,
|
||||
savedResponse.mHasBodyId = !nullBody;
|
||||
|
||||
if (savedResponse.mHasBodyId) {
|
||||
CACHE_TRY_VAR(savedResponse.mBodyId, ExtractId(*state, 4));
|
||||
CACHE_TRY_UNWRAP(savedResponse.mBodyId, ExtractId(*state, 4));
|
||||
}
|
||||
|
||||
nsAutoCString serializedInfo;
|
||||
@ -2516,7 +2517,7 @@ Result<SavedRequest, nsresult> ReadRequest(mozIStorageConnection& aConn,
|
||||
}
|
||||
savedRequest.mHasBodyId = !nullBody;
|
||||
if (savedRequest.mHasBodyId) {
|
||||
CACHE_TRY_VAR(savedRequest.mBodyId, ExtractId(*state, 13));
|
||||
CACHE_TRY_UNWRAP(savedRequest.mBodyId, ExtractId(*state, 13));
|
||||
}
|
||||
rv = aConn.CreateStatement(nsLiteralCString("SELECT "
|
||||
"name, "
|
||||
@ -2815,7 +2816,7 @@ struct Expect {
|
||||
|
||||
nsresult Validate(mozIStorageConnection& aConn) {
|
||||
int32_t schemaVersion;
|
||||
CACHE_TRY_VAR(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
CACHE_TRY_UNWRAP(schemaVersion, GetEffectiveSchemaVersion(aConn));
|
||||
if (NS_WARN_IF(schemaVersion != kLatestSchemaVersion)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2973,7 +2974,7 @@ nsresult Migrate(mozIStorageConnection& aConn) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
int32_t currentVersion = 0;
|
||||
CACHE_TRY_VAR(currentVersion, GetEffectiveSchemaVersion(aConn));
|
||||
CACHE_TRY_UNWRAP(currentVersion, GetEffectiveSchemaVersion(aConn));
|
||||
|
||||
bool rewriteSchema = false;
|
||||
|
||||
@ -3000,7 +3001,7 @@ nsresult Migrate(mozIStorageConnection& aConn) {
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
int32_t lastVersion = currentVersion;
|
||||
#endif
|
||||
CACHE_TRY_VAR(currentVersion, GetEffectiveSchemaVersion(aConn));
|
||||
CACHE_TRY_UNWRAP(currentVersion, GetEffectiveSchemaVersion(aConn));
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(currentVersion > lastVersion);
|
||||
}
|
||||
|
8
dom/cache/FileUtils.cpp
vendored
8
dom/cache/FileUtils.cpp
vendored
@ -871,7 +871,7 @@ nsresult LockedUpdateDirectoryPaddingFile(nsIFile* aBaseDir,
|
||||
|
||||
// We don't need to add the aIncreaseSize or aDecreaseSize here, because
|
||||
// it's already encompassed within the database.
|
||||
CACHE_TRY_VAR(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
CACHE_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
} else {
|
||||
bool shouldRevise = false;
|
||||
if (aIncreaseSize > 0) {
|
||||
@ -900,7 +900,7 @@ nsresult LockedUpdateDirectoryPaddingFile(nsIFile* aBaseDir,
|
||||
return rv;
|
||||
}
|
||||
|
||||
CACHE_TRY_VAR(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
CACHE_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
|
||||
// XXXtt: we should have an easy way to update (increase or recalulate)
|
||||
// padding size in the QM. For now, only correct the padding size in
|
||||
@ -912,7 +912,7 @@ nsresult LockedUpdateDirectoryPaddingFile(nsIFile* aBaseDir,
|
||||
|
||||
#ifdef DEBUG
|
||||
int64_t lastPaddingSize = currentPaddingSize;
|
||||
CACHE_TRY_VAR(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
CACHE_TRY_UNWRAP(currentPaddingSize, db::FindOverallPaddingSize(*aConn));
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(currentPaddingSize == lastPaddingSize);
|
||||
#endif // DEBUG
|
||||
@ -984,7 +984,7 @@ nsresult LockedDirectoryPaddingRestore(nsIFile* aBaseDir,
|
||||
return rv;
|
||||
}
|
||||
|
||||
CACHE_TRY_VAR(*aPaddingSizeOut, db::FindOverallPaddingSize(*aConn));
|
||||
CACHE_TRY_UNWRAP(*aPaddingSizeOut, db::FindOverallPaddingSize(*aConn));
|
||||
MOZ_DIAGNOSTIC_ASSERT(*aPaddingSizeOut >= 0);
|
||||
|
||||
rv = LockedDirectoryPaddingWrite(aBaseDir, DirPaddingFile::FILE,
|
||||
|
38
dom/cache/Manager.cpp
vendored
38
dom/cache/Manager.cpp
vendored
@ -102,13 +102,13 @@ class SetupAction final : public SyncDBAction {
|
||||
|
||||
// Clean up orphaned Cache objects
|
||||
AutoTArray<CacheId, 8> orphanedCacheIdList;
|
||||
CACHE_TRY_VAR(orphanedCacheIdList, db::FindOrphanedCacheIds(*aConn));
|
||||
CACHE_TRY_UNWRAP(orphanedCacheIdList, db::FindOrphanedCacheIds(*aConn));
|
||||
|
||||
int64_t overallDeletedPaddingSize = 0;
|
||||
for (uint32_t i = 0; i < orphanedCacheIdList.Length(); ++i) {
|
||||
DeletionInfo deletionInfo;
|
||||
CACHE_TRY_VAR(deletionInfo,
|
||||
db::DeleteCacheId(*aConn, orphanedCacheIdList[i]));
|
||||
CACHE_TRY_UNWRAP(deletionInfo,
|
||||
db::DeleteCacheId(*aConn, orphanedCacheIdList[i]));
|
||||
|
||||
rv = BodyDeleteFiles(aQuotaInfo, aDBDir,
|
||||
deletionInfo.mDeletedBodyIdList);
|
||||
@ -128,7 +128,7 @@ class SetupAction final : public SyncDBAction {
|
||||
|
||||
// Clean up orphaned body objects
|
||||
AutoTArray<nsID, 64> knownBodyIdList;
|
||||
CACHE_TRY_VAR(knownBodyIdList, db::GetKnownBodyIds(*aConn));
|
||||
CACHE_TRY_UNWRAP(knownBodyIdList, db::GetKnownBodyIds(*aConn));
|
||||
|
||||
rv = BodyDeleteOrphanedFiles(aQuotaInfo, aDBDir, knownBodyIdList);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -489,7 +489,7 @@ class Manager::DeleteOrphanedCacheAction final : public SyncDBAction {
|
||||
mozStorageTransaction trans(aConn, false,
|
||||
mozIStorageConnection::TRANSACTION_IMMEDIATE);
|
||||
|
||||
CACHE_TRY_VAR(mDeletionInfo, db::DeleteCacheId(*aConn, mCacheId));
|
||||
CACHE_TRY_UNWRAP(mDeletionInfo, db::DeleteCacheId(*aConn, mCacheId));
|
||||
|
||||
nsresult rv = MaybeUpdatePaddingFile(
|
||||
aDBDir, aConn, /* aIncreaceSize */ 0, mDeletionInfo.mDeletedPaddingSize,
|
||||
@ -542,7 +542,7 @@ class Manager::CacheMatchAction final : public Manager::BaseAction {
|
||||
const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
|
||||
mozIStorageConnection* aConn) override {
|
||||
Maybe<SavedResponse> maybeResponse;
|
||||
CACHE_TRY_VAR(
|
||||
CACHE_TRY_UNWRAP(
|
||||
maybeResponse,
|
||||
db::CacheMatch(*aConn, mCacheId, mArgs.request(), mArgs.params()));
|
||||
|
||||
@ -612,9 +612,9 @@ class Manager::CacheMatchAllAction final : public Manager::BaseAction {
|
||||
virtual nsresult RunSyncWithDBOnTarget(
|
||||
const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
|
||||
mozIStorageConnection* aConn) override {
|
||||
CACHE_TRY_VAR(mSavedResponses,
|
||||
db::CacheMatchAll(*aConn, mCacheId, mArgs.maybeRequest(),
|
||||
mArgs.params()));
|
||||
CACHE_TRY_UNWRAP(mSavedResponses,
|
||||
db::CacheMatchAll(*aConn, mCacheId, mArgs.maybeRequest(),
|
||||
mArgs.params()));
|
||||
|
||||
for (uint32_t i = 0; i < mSavedResponses.Length(); ++i) {
|
||||
if (!mSavedResponses[i].mHasBodyId ||
|
||||
@ -1082,7 +1082,7 @@ class Manager::CacheDeleteAction final : public Manager::BaseAction {
|
||||
mozIStorageConnection::TRANSACTION_IMMEDIATE);
|
||||
|
||||
Maybe<DeletionInfo> maybeDeletionInfo;
|
||||
CACHE_TRY_VAR(
|
||||
CACHE_TRY_UNWRAP(
|
||||
maybeDeletionInfo,
|
||||
db::CacheDelete(*aConn, mCacheId, mArgs.request(), mArgs.params()));
|
||||
|
||||
@ -1147,7 +1147,7 @@ class Manager::CacheKeysAction final : public Manager::BaseAction {
|
||||
virtual nsresult RunSyncWithDBOnTarget(
|
||||
const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
|
||||
mozIStorageConnection* aConn) override {
|
||||
CACHE_TRY_VAR(
|
||||
CACHE_TRY_UNWRAP(
|
||||
mSavedRequests,
|
||||
db::CacheKeys(*aConn, mCacheId, mArgs.maybeRequest(), mArgs.params()));
|
||||
|
||||
@ -1278,8 +1278,8 @@ class Manager::StorageHasAction final : public Manager::BaseAction {
|
||||
const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
|
||||
mozIStorageConnection* aConn) override {
|
||||
Maybe<CacheId> maybeCacheId;
|
||||
CACHE_TRY_VAR(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
CACHE_TRY_UNWRAP(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
|
||||
mCacheFound = maybeCacheId.isSome();
|
||||
|
||||
@ -1316,8 +1316,8 @@ class Manager::StorageOpenAction final : public Manager::BaseAction {
|
||||
|
||||
// Look for existing cache
|
||||
Maybe<CacheId> maybeCacheId;
|
||||
CACHE_TRY_VAR(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
CACHE_TRY_UNWRAP(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
|
||||
if (maybeCacheId.isSome()) {
|
||||
mCacheId = maybeCacheId.ref();
|
||||
@ -1325,7 +1325,7 @@ class Manager::StorageOpenAction final : public Manager::BaseAction {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CACHE_TRY_VAR(mCacheId, db::CreateCacheId(*aConn));
|
||||
CACHE_TRY_UNWRAP(mCacheId, db::CreateCacheId(*aConn));
|
||||
|
||||
nsresult rv =
|
||||
db::StoragePutCache(*aConn, mNamespace, mArgs.key(), mCacheId);
|
||||
@ -1374,8 +1374,8 @@ class Manager::StorageDeleteAction final : public Manager::BaseAction {
|
||||
mozIStorageConnection::TRANSACTION_IMMEDIATE);
|
||||
|
||||
Maybe<CacheId> maybeCacheId;
|
||||
CACHE_TRY_VAR(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
CACHE_TRY_UNWRAP(maybeCacheId,
|
||||
db::StorageGetCacheId(*aConn, mNamespace, mArgs.key()));
|
||||
|
||||
if (maybeCacheId.isNothing()) {
|
||||
mCacheDeleted = false;
|
||||
@ -1439,7 +1439,7 @@ class Manager::StorageKeysAction final : public Manager::BaseAction {
|
||||
virtual nsresult RunSyncWithDBOnTarget(
|
||||
const QuotaInfo& aQuotaInfo, nsIFile* aDBDir,
|
||||
mozIStorageConnection* aConn) override {
|
||||
CACHE_TRY_VAR(mKeys, db::StorageGetKeys(*aConn, mNamespace));
|
||||
CACHE_TRY_UNWRAP(mKeys, db::StorageGetKeys(*aConn, mNamespace));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
3
dom/cache/QuotaClient.cpp
vendored
3
dom/cache/QuotaClient.cpp
vendored
@ -388,7 +388,8 @@ Result<UsageInfo, nsresult> CacheQuotaClient::GetUsageForOriginInternal(
|
||||
QuotaManager* qm = QuotaManager::Get();
|
||||
MOZ_DIAGNOSTIC_ASSERT(qm);
|
||||
|
||||
CACHE_TRY_VAR(auto dir, qm->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
CACHE_TRY_UNWRAP(auto dir,
|
||||
qm->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
|
||||
nsresult rv =
|
||||
dir->Append(NS_LITERAL_STRING_FROM_CSTRING(DOMCACHE_DIRECTORY_NAME));
|
||||
|
@ -784,8 +784,9 @@ class WorkerPermissionChallenge final : public Runnable {
|
||||
return true;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto principal,
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(mPrincipalInfo), true);
|
||||
IDB_TRY_UNWRAP(auto principal,
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(mPrincipalInfo),
|
||||
true);
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
const nsCOMPtr<Element> ownerElement =
|
||||
@ -1466,9 +1467,9 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto principal,
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aPrincipalInfo),
|
||||
IPC_FAIL_NO_REASON(this));
|
||||
IDB_TRY_UNWRAP(auto principal,
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aPrincipalInfo),
|
||||
IPC_FAIL_NO_REASON(this));
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
nsCOMPtr<nsIGlobalObject> global = mFactory->GetParentObject();
|
||||
|
@ -610,7 +610,7 @@ Result<nsCOMPtr<nsIFileURL>, nsresult> GetDatabaseFileURL(
|
||||
? "&directoryLockId="_ns + IntCString(aDirectoryLockId)
|
||||
: EmptyCString();
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
auto result, ([&mutator, &directoryLockIdClause] {
|
||||
nsCOMPtr<nsIFileURL> result;
|
||||
nsresult rv = NS_MutateURI(mutator)
|
||||
@ -685,12 +685,12 @@ nsresult SetDefaultPragmas(mozIStorageConnection& aConnection) {
|
||||
Result<nsCOMPtr<mozIStorageStatement>, nsresult>
|
||||
CreateAndExecuteSingleStepStatement(mozIStorageConnection& aConnection,
|
||||
const nsACString& aStatementString) {
|
||||
IDB_TRY_VAR(auto stmt, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageStatement>, aConnection,
|
||||
CreateStatement, aStatementString));
|
||||
IDB_TRY_UNWRAP(auto stmt, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageStatement>, aConnection,
|
||||
CreateStatement, aStatementString));
|
||||
|
||||
IDB_TRY_VAR(const DebugOnly<bool> hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
IDB_TRY_UNWRAP(const DebugOnly<bool> hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
MOZ_ASSERT(hasResult);
|
||||
|
||||
return stmt;
|
||||
@ -807,7 +807,7 @@ OpenDatabaseAndHandleBusy(mozIStorageService& aStorageService,
|
||||
|
||||
using ConnectionType = Maybe<MovingNotNull<nsCOMPtr<mozIStorageConnection>>>;
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
auto connection,
|
||||
StorageOpenTraits<FileOrURLType>::Open(aStorageService, aFileOrURL,
|
||||
aTelemetryId)
|
||||
@ -837,7 +837,7 @@ OpenDatabaseAndHandleBusy(mozIStorageService& aStorageService,
|
||||
do {
|
||||
PR_Sleep(PR_MillisecondsToInterval(100));
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
connection,
|
||||
StorageOpenTraits<FileOrURLType>::Open(aStorageService, aFileOrURL,
|
||||
aTelemetryId)
|
||||
@ -904,7 +904,7 @@ CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
|
||||
ToResultGet<nsCOMPtr<mozIStorageService>>(
|
||||
MOZ_SELECT_OVERLOAD(do_GetService), MOZ_STORAGE_SERVICE_CONTRACTID));
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
auto connection,
|
||||
OpenDatabaseAndHandleBusy(*storageService, *dbFileUrl, aTelemetryId)
|
||||
.map([](auto connection) -> nsCOMPtr<mozIStorageConnection> {
|
||||
@ -934,8 +934,8 @@ CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
|
||||
IDB_TRY(aFMDirectory.Remove(true));
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(connection, OpenDatabaseAndHandleBusy(
|
||||
*storageService, *dbFileUrl, aTelemetryId));
|
||||
IDB_TRY_UNWRAP(connection, OpenDatabaseAndHandleBusy(
|
||||
*storageService, *dbFileUrl, aTelemetryId));
|
||||
}
|
||||
|
||||
IDB_TRY(SetDefaultPragmas(*connection));
|
||||
@ -1023,8 +1023,9 @@ CreateStorageConnection(nsIFile& aDBFile, nsIFile& aFMDirectory,
|
||||
IDB_TRY(stmt->BindUTF8StringByIndex(1, aOrigin));
|
||||
IDB_TRY(stmt->Execute());
|
||||
} else {
|
||||
IDB_TRY_VAR(vacuumNeeded, MaybeUpgradeSchema(*connection, schemaVersion,
|
||||
aFMDirectory, aOrigin));
|
||||
IDB_TRY_UNWRAP(vacuumNeeded,
|
||||
MaybeUpgradeSchema(*connection, schemaVersion,
|
||||
aFMDirectory, aOrigin));
|
||||
}
|
||||
|
||||
IDB_TRY(MOZ_TO_RESULT_INVOKE(transaction, Commit)
|
||||
@ -1160,8 +1161,8 @@ GetStorageConnection(nsIFile& aDatabaseFile, const int64_t aDirectoryLockId,
|
||||
return Err(rv);
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(nsCOMPtr<mozIStorageConnection> connection,
|
||||
OpenDatabaseAndHandleBusy(*ss, *dbFileUrl, aTelemetryId));
|
||||
IDB_TRY_UNWRAP(nsCOMPtr<mozIStorageConnection> connection,
|
||||
OpenDatabaseAndHandleBusy(*ss, *dbFileUrl, aTelemetryId));
|
||||
|
||||
rv = SetDefaultPragmas(*connection);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -5931,8 +5932,9 @@ Result<nsCOMPtr<nsIFile>, nsresult> CreateMarkerFile(
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(!aDatabaseNameBase.IsEmpty());
|
||||
|
||||
IDB_TRY_VAR(auto markerFile, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<nsIFile>, aBaseDirectory, Clone));
|
||||
IDB_TRY_UNWRAP(
|
||||
auto markerFile,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aBaseDirectory, Clone));
|
||||
|
||||
IDB_TRY(markerFile->Append(kIdbDeletionMarkerFilePrefix + aDatabaseNameBase));
|
||||
|
||||
@ -5967,7 +5969,7 @@ Result<mozilla::Ok, nsresult> DeleteFileManagerDirectory(
|
||||
return mozilla::Ok{};
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto fileUsage, FileManager::GetUsage(&aFileManagerDirectory));
|
||||
IDB_TRY_UNWRAP(auto fileUsage, FileManager::GetUsage(&aFileManagerDirectory));
|
||||
|
||||
uint64_t usageValue = fileUsage.GetValue().valueOr(0);
|
||||
|
||||
@ -6022,8 +6024,8 @@ nsresult RemoveDatabaseFilesAndDirectory(nsIFile& aBaseDirectory,
|
||||
|
||||
AUTO_PROFILER_LABEL("RemoveDatabaseFilesAndDirectory", DOM);
|
||||
|
||||
IDB_TRY_VAR(auto markerFile,
|
||||
CreateMarkerFile(aBaseDirectory, aDatabaseFilenameBase));
|
||||
IDB_TRY_UNWRAP(auto markerFile,
|
||||
CreateMarkerFile(aBaseDirectory, aDatabaseFilenameBase));
|
||||
|
||||
// The database file counts towards quota.
|
||||
IDB_TRY(DeleteFile(aBaseDirectory, aDatabaseFilenameBase + kSQLiteSuffix,
|
||||
@ -6540,9 +6542,9 @@ struct ValuePopulateResponseHelper {
|
||||
const ValueCursorBase& aCursor) {
|
||||
constexpr auto offset = StatementHasIndexKeyBindings ? 2 : 0;
|
||||
|
||||
IDB_TRY_VAR(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
aStmt, 2 + offset, 1 + offset, *aCursor.mFileManager));
|
||||
IDB_TRY_UNWRAP(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
aStmt, 2 + offset, 1 + offset, *aCursor.mFileManager));
|
||||
|
||||
mCloneInfo.init(std::move(cloneInfo));
|
||||
|
||||
@ -7094,7 +7096,7 @@ DatabaseConnection::GetCachedStatement(const nsACString& aQuery) {
|
||||
const auto extraInfo =
|
||||
ScopedLogExtraInfo{ScopedLogExtraInfo::kTagQuery, aQuery};
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
stmt,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageStatement>,
|
||||
**mStorageConnection, CreateStatement,
|
||||
@ -7123,7 +7125,7 @@ DatabaseConnection::GetCachedStatement(const nsACString& aQuery) {
|
||||
|
||||
Result<DatabaseConnection::BorrowedStatement, nsresult>
|
||||
DatabaseConnection::BorrowCachedStatement(const nsACString& aQuery) {
|
||||
IDB_TRY_VAR(auto cachedStatement, GetCachedStatement(aQuery));
|
||||
IDB_TRY_UNWRAP(auto cachedStatement, GetCachedStatement(aQuery));
|
||||
|
||||
return cachedStatement.Borrow();
|
||||
}
|
||||
@ -7399,8 +7401,8 @@ void DatabaseConnection::DoIdleProcessing(bool aNeedsCheckpoint) {
|
||||
CachedStatement rollbackStmt;
|
||||
CachedStatement beginStmt;
|
||||
if (aNeedsCheckpoint || freelistCount) {
|
||||
IDB_TRY_VAR(rollbackStmt, GetCachedStatement("ROLLBACK;"_ns), QM_VOID);
|
||||
IDB_TRY_VAR(beginStmt, GetCachedStatement("BEGIN;"_ns), QM_VOID);
|
||||
IDB_TRY_UNWRAP(rollbackStmt, GetCachedStatement("ROLLBACK;"_ns), QM_VOID);
|
||||
IDB_TRY_UNWRAP(beginStmt, GetCachedStatement("BEGIN;"_ns), QM_VOID);
|
||||
|
||||
// Release the connection's normal transaction. It's possible that it could
|
||||
// fail, but that isn't a problem here.
|
||||
@ -7550,14 +7552,14 @@ nsresult DatabaseConnection::GetFreelistCount(CachedStatement& aCachedStatement,
|
||||
nsresult rv;
|
||||
|
||||
if (!aCachedStatement) {
|
||||
IDB_TRY_VAR(aCachedStatement,
|
||||
GetCachedStatement("PRAGMA freelist_count;"_ns));
|
||||
IDB_TRY_UNWRAP(aCachedStatement,
|
||||
GetCachedStatement("PRAGMA freelist_count;"_ns));
|
||||
}
|
||||
|
||||
const auto borrowedStatement = aCachedStatement.Borrow();
|
||||
|
||||
IDB_TRY_VAR(const DebugOnly<bool> hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*borrowedStatement, ExecuteStep));
|
||||
IDB_TRY_UNWRAP(const DebugOnly<bool> hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*borrowedStatement, ExecuteStep));
|
||||
|
||||
MOZ_ASSERT(hasResult);
|
||||
|
||||
@ -7662,7 +7664,7 @@ nsresult DatabaseConnection::GetFileSize(const nsAString& aPath,
|
||||
MOZ_ASSERT(!aPath.IsEmpty());
|
||||
MOZ_ASSERT(aResult);
|
||||
|
||||
IDB_TRY_VAR(auto file, QM_NewLocalFile(aPath));
|
||||
IDB_TRY_UNWRAP(auto file, QM_NewLocalFile(aPath));
|
||||
|
||||
int64_t fileSize;
|
||||
|
||||
@ -8148,10 +8150,10 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
|
||||
if (!mUpdateStatement) {
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_TRY_VAR(mUpdateStatement, connection->GetCachedStatement(
|
||||
"UPDATE file "
|
||||
"SET refcount = refcount + :delta "
|
||||
"WHERE id = :id"_ns));
|
||||
IDB_TRY_UNWRAP(mUpdateStatement, connection->GetCachedStatement(
|
||||
"UPDATE file "
|
||||
"SET refcount = refcount + :delta "
|
||||
"WHERE id = :id"_ns));
|
||||
}
|
||||
|
||||
{
|
||||
@ -8183,10 +8185,10 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
|
||||
if (!mSelectStatement) {
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_TRY_VAR(mSelectStatement,
|
||||
connection->GetCachedStatement("SELECT id "
|
||||
"FROM file "
|
||||
"WHERE id = :id"_ns));
|
||||
IDB_TRY_UNWRAP(mSelectStatement,
|
||||
connection->GetCachedStatement("SELECT id "
|
||||
"FROM file "
|
||||
"WHERE id = :id"_ns));
|
||||
}
|
||||
|
||||
const auto borrowedSelectStatement = mSelectStatement.Borrow();
|
||||
@ -8212,9 +8214,10 @@ nsresult DatabaseConnection::UpdateRefcountFunction::DatabaseUpdateFunction::
|
||||
if (!mInsertStatement) {
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_TRY_VAR(mInsertStatement,
|
||||
connection->GetCachedStatement(
|
||||
"INSERT INTO file (id, refcount) VALUES(:id, :delta)"_ns));
|
||||
IDB_TRY_UNWRAP(
|
||||
mInsertStatement,
|
||||
connection->GetCachedStatement(
|
||||
"INSERT INTO file (id, refcount) VALUES(:id, :delta)"_ns));
|
||||
}
|
||||
|
||||
const auto borrowedInsertStatement = mInsertStatement.Borrow();
|
||||
@ -8347,7 +8350,7 @@ ConnectionPool::GetOrCreateConnection(const Database& aDatabase) {
|
||||
|
||||
MOZ_ASSERT(!dbInfo->mDEBUGConnectionThread);
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
MovingNotNull<nsCOMPtr<mozIStorageConnection>> storageConnection,
|
||||
GetStorageConnection(aDatabase.FilePath(), aDatabase.DirectoryLockId(),
|
||||
aDatabase.TelemetryId()));
|
||||
@ -10015,7 +10018,7 @@ nsresult Database::EnsureConnection() {
|
||||
AUTO_PROFILER_LABEL("Database::EnsureConnection", DOM);
|
||||
|
||||
if (!mConnection || !mConnection->HasStorageConnection()) {
|
||||
IDB_TRY_VAR(mConnection, gConnectionPool->GetOrCreateConnection(*this));
|
||||
IDB_TRY_UNWRAP(mConnection, gConnectionPool->GetOrCreateConnection(*this));
|
||||
}
|
||||
|
||||
AssertIsOnConnectionThread();
|
||||
@ -10483,7 +10486,7 @@ Database::AllocPBackgroundIDBTransactionParent(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
auto objectStoreMetadatas,
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
aObjectStoreNames,
|
||||
@ -12498,13 +12501,13 @@ void ValueCursorBase::ProcessFiles(CursorResponse& aResponse,
|
||||
MOZ_ASSERT(serializedInfo->files().IsEmpty());
|
||||
MOZ_ASSERT(this->mDatabase);
|
||||
|
||||
IDB_TRY_VAR(serializedInfo->files(),
|
||||
SerializeStructuredCloneFiles((*this->mBackgroundParent),
|
||||
this->mDatabase, files,
|
||||
/* aForPreprocess */ false),
|
||||
QM_VOID, [&aResponse](const nsresult result) {
|
||||
aResponse = ClampResultCode(result);
|
||||
});
|
||||
IDB_TRY_UNWRAP(serializedInfo->files(),
|
||||
SerializeStructuredCloneFiles((*this->mBackgroundParent),
|
||||
this->mDatabase, files,
|
||||
/* aForPreprocess */ false),
|
||||
QM_VOID, [&aResponse](const nsresult result) {
|
||||
aResponse = ClampResultCode(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12589,7 +12592,7 @@ mozilla::ipc::IPCResult Cursor<CursorType>::RecvContinue(
|
||||
|
||||
MOZ_ASSERT(!aCurrentKey.IsUnset());
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
auto position,
|
||||
([&]() -> Result<CursorPosition<CursorType>, mozilla::ipc::IPCResult> {
|
||||
if constexpr (IsIndexCursor) {
|
||||
@ -12665,14 +12668,15 @@ nsresult FileManager::Init(nsIFile* aDirectory,
|
||||
IDB_TRY(aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755));
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto path,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsString, aDirectory, GetPath));
|
||||
IDB_TRY_UNWRAP(auto path,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsString, aDirectory, GetPath));
|
||||
|
||||
mDirectoryPath.init(std::move(path));
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto journalDirectory,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||
IDB_TRY_INSPECT(
|
||||
const auto& journalDirectory,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||
|
||||
IDB_TRY(journalDirectory->Append(kJournalDirectoryName));
|
||||
|
||||
@ -12683,8 +12687,8 @@ nsresult FileManager::Init(nsIFile* aDirectory,
|
||||
Unused << existsAsDirectory;
|
||||
|
||||
{
|
||||
IDB_TRY_VAR(auto path, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsString, journalDirectory, GetPath));
|
||||
IDB_TRY_UNWRAP(auto path, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsString, journalDirectory, GetPath));
|
||||
|
||||
mJournalDirectoryPath.init(std::move(path));
|
||||
}
|
||||
@ -12793,9 +12797,10 @@ nsCOMPtr<nsIFile> FileManager::GetFileForId(nsIFile* aDirectory, int64_t aId) {
|
||||
nsAutoString id;
|
||||
id.AppendInt(aId);
|
||||
|
||||
IDB_TRY_VAR(auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone),
|
||||
nullptr);
|
||||
IDB_TRY_UNWRAP(
|
||||
auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone),
|
||||
nullptr);
|
||||
|
||||
IDB_TRY(file->Append(id), nullptr);
|
||||
|
||||
@ -12884,10 +12889,10 @@ nsresult FileManager::InitDirectory(nsIFile& aDirectory, nsIFile& aDatabaseFile,
|
||||
}));
|
||||
|
||||
if (hasJournals) {
|
||||
IDB_TRY_VAR(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
CreateStorageConnection(
|
||||
aDatabaseFile, aDirectory, VoidString(), aOrigin,
|
||||
/* aDirectoryLockId */ -1, aTelemetryId));
|
||||
IDB_TRY_UNWRAP(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
CreateStorageConnection(
|
||||
aDatabaseFile, aDirectory, VoidString(), aOrigin,
|
||||
/* aDirectoryLockId */ -1, aTelemetryId));
|
||||
|
||||
mozStorageTransaction transaction(connection.get(), false);
|
||||
|
||||
@ -12896,8 +12901,8 @@ nsresult FileManager::InitDirectory(nsIFile& aDirectory, nsIFile& aDatabaseFile,
|
||||
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_TRY_VAR(
|
||||
auto stmt,
|
||||
IDB_TRY_INSPECT(
|
||||
const auto& stmt,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageStatement>, *connection, CreateStatement,
|
||||
"SELECT name, (name IN (SELECT id FROM file)) FROM fs WHERE path = :path"_ns));
|
||||
@ -13756,8 +13761,8 @@ nsresult QuotaClient::GetDirectory(PersistenceType aPersistenceType,
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
NS_ASSERTION(quotaManager, "This should never fail!");
|
||||
|
||||
IDB_TRY_VAR(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
IDB_TRY_UNWRAP(auto directory, quotaManager->GetDirectoryForOrigin(
|
||||
aPersistenceType, aOrigin));
|
||||
|
||||
MOZ_ASSERT(directory);
|
||||
|
||||
@ -14688,10 +14693,10 @@ void DatabaseMaintenance::PerformMaintenanceOnDatabase() {
|
||||
const nsCOMPtr<nsIFile> databaseFile = GetFileForPath(mDatabasePath);
|
||||
MOZ_ASSERT(databaseFile);
|
||||
|
||||
IDB_TRY_VAR(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
GetStorageConnection(*databaseFile, mDirectoryLockId,
|
||||
TelemetryIdForFile(databaseFile)),
|
||||
QM_VOID);
|
||||
IDB_TRY_UNWRAP(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
GetStorageConnection(*databaseFile, mDirectoryLockId,
|
||||
TelemetryIdForFile(databaseFile)),
|
||||
QM_VOID);
|
||||
|
||||
AutoClose autoClose(connection);
|
||||
|
||||
@ -14799,7 +14804,7 @@ nsresult DatabaseMaintenance::CheckIntegrity(mozIStorageConnection& aConnection,
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(foreignKeyError, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
IDB_TRY_UNWRAP(foreignKeyError, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
}
|
||||
|
||||
if (!foreignKeysWereEnabled) {
|
||||
@ -15385,7 +15390,7 @@ nsresult DatabaseOperationBase::InsertIndexTableRows(
|
||||
info.mUnique ? insertUniqueStmt : insertStmt;
|
||||
|
||||
if (!stmt) {
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
stmt,
|
||||
aConnection->GetCachedStatement(
|
||||
info.mUnique
|
||||
@ -15475,7 +15480,7 @@ nsresult DatabaseOperationBase::DeleteIndexDataTableRows(
|
||||
indexValue.mUnique ? deleteUniqueStmt : deleteStmt;
|
||||
|
||||
if (!stmt) {
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
stmt,
|
||||
aConnection->GetCachedStatement(
|
||||
indexValue.mUnique
|
||||
@ -15544,18 +15549,18 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
|
||||
|
||||
nsresult rv;
|
||||
Key objectStoreKey;
|
||||
IDB_TRY_VAR(
|
||||
const auto selectStmt,
|
||||
IDB_TRY_INSPECT(
|
||||
const auto& selectStmt,
|
||||
([singleRowOnly, &aConnection, &objectStoreKey, &aKeyRange]()
|
||||
-> Result<DatabaseConnection::BorrowedStatement, nsresult> {
|
||||
if (singleRowOnly) {
|
||||
IDB_TRY_VAR(auto selectStmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT index_data_values "
|
||||
"FROM object_data "
|
||||
"WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + " AND key = :"_ns +
|
||||
kStmtParamNameKey + ";"_ns));
|
||||
IDB_TRY_UNWRAP(auto selectStmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT index_data_values "
|
||||
"FROM object_data "
|
||||
"WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + " AND key = :"_ns +
|
||||
kStmtParamNameKey + ";"_ns));
|
||||
|
||||
objectStoreKey = aKeyRange.ref().lower();
|
||||
|
||||
@ -15568,11 +15573,12 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
|
||||
const auto keyRangeClause =
|
||||
MaybeGetBindingClauseForKeyRange(aKeyRange, kColumnNameKey);
|
||||
|
||||
IDB_TRY_VAR(auto selectStmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT index_data_values, "_ns + kColumnNameKey +
|
||||
" FROM object_data WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + keyRangeClause + ";"_ns));
|
||||
IDB_TRY_UNWRAP(
|
||||
auto selectStmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT index_data_values, "_ns + kColumnNameKey +
|
||||
" FROM object_data WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + keyRangeClause + ";"_ns));
|
||||
|
||||
if (aKeyRange.isSome()) {
|
||||
IDB_TRY(BindKeyRangeToStatement(aKeyRange.ref(), &*selectStmt));
|
||||
@ -15605,12 +15611,12 @@ nsresult DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
|
||||
DeleteIndexDataTableRows(aConnection, objectStoreKey, indexValues));
|
||||
|
||||
if (!deleteStmt) {
|
||||
IDB_TRY_VAR(deleteStmt,
|
||||
aConnection->GetCachedStatement(
|
||||
"DELETE FROM object_data "
|
||||
"WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + " AND key = :"_ns +
|
||||
kStmtParamNameKey + ";"_ns));
|
||||
IDB_TRY_UNWRAP(deleteStmt,
|
||||
aConnection->GetCachedStatement(
|
||||
"DELETE FROM object_data "
|
||||
"WHERE object_store_id = :"_ns +
|
||||
kStmtParamNameObjectStoreId + " AND key = :"_ns +
|
||||
kStmtParamNameKey + ";"_ns));
|
||||
}
|
||||
|
||||
const auto borrowedDeleteStmt = deleteStmt.Borrow();
|
||||
@ -15641,8 +15647,8 @@ nsresult DatabaseOperationBase::UpdateIndexValues(
|
||||
|
||||
AUTO_PROFILER_LABEL("DatabaseOperationBase::UpdateIndexValues", DOM);
|
||||
|
||||
IDB_TRY_VAR((auto [indexDataValues, indexDataValuesLength]),
|
||||
MakeCompressedIndexDataValues(aIndexValues));
|
||||
IDB_TRY_UNWRAP((auto [indexDataValues, indexDataValuesLength]),
|
||||
MakeCompressedIndexDataValues(aIndexValues));
|
||||
|
||||
MOZ_ASSERT(!indexDataValuesLength == !(indexDataValues.get()));
|
||||
|
||||
@ -15707,7 +15713,8 @@ nsresult DatabaseOperationBase::ObjectStoreHasIndexes(
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
|
||||
*aHasIndexes = hasResult;
|
||||
return NS_OK;
|
||||
@ -16569,8 +16576,8 @@ nsresult FactoryOp::OpenDirectory() {
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
IDB_TRY_VAR(auto dbFile,
|
||||
quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin));
|
||||
IDB_TRY_UNWRAP(auto dbFile,
|
||||
quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin));
|
||||
|
||||
nsresult rv =
|
||||
dbFile->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
|
||||
@ -16916,9 +16923,10 @@ nsresult OpenDatabaseOp::DoDatabaseWork() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
CreateStorageConnection(*dbFile, *fmDirectory, databaseName,
|
||||
mOrigin, mDirectoryLockId, mTelemetryId));
|
||||
IDB_TRY_UNWRAP(
|
||||
NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
CreateStorageConnection(*dbFile, *fmDirectory, databaseName, mOrigin,
|
||||
mDirectoryLockId, mTelemetryId));
|
||||
|
||||
AutoSetProgressHandler asph;
|
||||
rv = asph.Register(*connection, this);
|
||||
@ -17004,7 +17012,8 @@ nsresult OpenDatabaseOp::LoadDatabaseInformation(
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
return NS_ERROR_FILE_CORRUPTED;
|
||||
@ -17291,7 +17300,7 @@ nsresult OpenDatabaseOp::UpdateLocaleAwareIndex(
|
||||
writeStmt = nsCOMPtr<mozIStorageStatement>{}](
|
||||
auto& readStmt) mutable -> mozilla::Result<mozilla::Ok, nsresult> {
|
||||
if (!writeStmt) {
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
writeStmt,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageStatement>, aConnection, CreateStatement,
|
||||
@ -17697,37 +17706,37 @@ Result<DatabaseSpec, nsresult> OpenDatabaseOp::MetadataToSpec() const {
|
||||
DatabaseSpec spec;
|
||||
spec.metadata() = mMetadata->mCommonMetadata;
|
||||
|
||||
IDB_TRY_VAR(spec.objectStores(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
mMetadata->mObjectStores,
|
||||
[](const auto& objectStoreEntry)
|
||||
-> mozilla::Result<ObjectStoreSpec, nsresult> {
|
||||
FullObjectStoreMetadata* metadata =
|
||||
objectStoreEntry.GetData();
|
||||
MOZ_ASSERT(objectStoreEntry.GetKey());
|
||||
MOZ_ASSERT(metadata);
|
||||
IDB_TRY_UNWRAP(
|
||||
spec.objectStores(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
mMetadata->mObjectStores,
|
||||
[](const auto& objectStoreEntry)
|
||||
-> mozilla::Result<ObjectStoreSpec, nsresult> {
|
||||
FullObjectStoreMetadata* metadata = objectStoreEntry.GetData();
|
||||
MOZ_ASSERT(objectStoreEntry.GetKey());
|
||||
MOZ_ASSERT(metadata);
|
||||
|
||||
ObjectStoreSpec objectStoreSpec;
|
||||
objectStoreSpec.metadata() = metadata->mCommonMetadata;
|
||||
ObjectStoreSpec objectStoreSpec;
|
||||
objectStoreSpec.metadata() = metadata->mCommonMetadata;
|
||||
|
||||
IDB_TRY_VAR(auto indexes,
|
||||
TransformIntoNewArray(
|
||||
metadata->mIndexes,
|
||||
[](const auto& indexEntry) {
|
||||
FullIndexMetadata* indexMetadata =
|
||||
indexEntry.GetData();
|
||||
MOZ_ASSERT(indexEntry.GetKey());
|
||||
MOZ_ASSERT(indexMetadata);
|
||||
IDB_TRY_UNWRAP(auto indexes,
|
||||
TransformIntoNewArray(
|
||||
metadata->mIndexes,
|
||||
[](const auto& indexEntry) {
|
||||
FullIndexMetadata* indexMetadata =
|
||||
indexEntry.GetData();
|
||||
MOZ_ASSERT(indexEntry.GetKey());
|
||||
MOZ_ASSERT(indexMetadata);
|
||||
|
||||
return indexMetadata->mCommonMetadata;
|
||||
},
|
||||
fallible));
|
||||
return indexMetadata->mCommonMetadata;
|
||||
},
|
||||
fallible));
|
||||
|
||||
objectStoreSpec.indexes() = std::move(indexes);
|
||||
objectStoreSpec.indexes() = std::move(indexes);
|
||||
|
||||
return objectStoreSpec;
|
||||
},
|
||||
fallible));
|
||||
return objectStoreSpec;
|
||||
},
|
||||
fallible));
|
||||
|
||||
return spec;
|
||||
}
|
||||
@ -17936,8 +17945,8 @@ void DeleteDatabaseOp::LoadPreviousVersion(nsIFile& aDatabaseFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
OpenDatabaseAndHandleBusy(*ss, aDatabaseFile), QM_VOID);
|
||||
IDB_TRY_UNWRAP(const NotNull<nsCOMPtr<mozIStorageConnection>> connection,
|
||||
OpenDatabaseAndHandleBusy(*ss, aDatabaseFile), QM_VOID);
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -17948,8 +17957,8 @@ void DeleteDatabaseOp::LoadPreviousVersion(nsIFile& aDatabaseFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep),
|
||||
QM_VOID);
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep), QM_VOID);
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
return;
|
||||
}
|
||||
@ -17971,8 +17980,8 @@ void DeleteDatabaseOp::LoadPreviousVersion(nsIFile& aDatabaseFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep),
|
||||
QM_VOID);
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep), QM_VOID);
|
||||
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
return;
|
||||
@ -18022,8 +18031,8 @@ nsresult DeleteDatabaseOp::DoDatabaseWork() {
|
||||
QuotaManager* const quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
IDB_TRY_VAR(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin));
|
||||
IDB_TRY_UNWRAP(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(persistenceType, mOrigin));
|
||||
|
||||
nsresult rv =
|
||||
directory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
|
||||
@ -18639,10 +18648,11 @@ nsresult TransactionBase::CommitOp::WriteAutoIncrementCounts() {
|
||||
if (!stmt) {
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_TRY_VAR(stmt, connection->GetCachedStatement(
|
||||
"UPDATE object_store "
|
||||
"SET auto_increment = :auto_increment WHERE id "
|
||||
"= :object_store_id;"_ns));
|
||||
IDB_TRY_UNWRAP(stmt,
|
||||
connection->GetCachedStatement(
|
||||
"UPDATE object_store "
|
||||
"SET auto_increment = :auto_increment WHERE id "
|
||||
"= :object_store_id;"_ns));
|
||||
}
|
||||
|
||||
const auto borrowedStmt = stmt.Borrow();
|
||||
@ -18701,7 +18711,7 @@ void TransactionBase::CommitOp::AssertForeignKeyConsistency(
|
||||
MOZ_ASSERT(mTransaction->GetMode() != IDBTransaction::Mode::ReadOnly);
|
||||
|
||||
{
|
||||
IDB_DEBUG_TRY_VAR(
|
||||
IDB_DEBUG_TRY_UNWRAP(
|
||||
const auto pragmaStmt,
|
||||
aConnection->BorrowCachedStatement("PRAGMA foreign_keys;"_ns), QM_VOID);
|
||||
|
||||
@ -18718,7 +18728,7 @@ void TransactionBase::CommitOp::AssertForeignKeyConsistency(
|
||||
}
|
||||
|
||||
{
|
||||
IDB_DEBUG_TRY_VAR(
|
||||
IDB_DEBUG_TRY_UNWRAP(
|
||||
const auto checkStmt,
|
||||
aConnection->BorrowCachedStatement("PRAGMA foreign_key_check;"_ns),
|
||||
QM_VOID);
|
||||
@ -19106,10 +19116,10 @@ nsresult CreateObjectStoreOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// have thrown an error long before now...
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_DEBUG_TRY_VAR(const auto stmt, aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store "
|
||||
"WHERE name = :name;"_ns));
|
||||
IDB_DEBUG_TRY_UNWRAP(const auto stmt, aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store "
|
||||
"WHERE name = :name;"_ns));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(stmt->BindStringByIndex(0, mMetadata.name()));
|
||||
|
||||
@ -19196,8 +19206,9 @@ nsresult DeleteObjectStoreOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// Make sure |mIsLastObjectStore| is telling the truth.
|
||||
IDB_DEBUG_TRY_VAR(const auto stmt, aConnection->BorrowCachedStatement(
|
||||
"SELECT id FROM object_store;"_ns));
|
||||
IDB_DEBUG_TRY_UNWRAP(
|
||||
const auto stmt,
|
||||
aConnection->BorrowCachedStatement("SELECT id FROM object_store;"_ns));
|
||||
|
||||
bool foundThisObjectStore = false;
|
||||
bool foundOtherObjectStore = false;
|
||||
@ -19375,11 +19386,11 @@ nsresult RenameObjectStoreOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// have thrown an error long before now...
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_DEBUG_TRY_VAR(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store "
|
||||
"WHERE name = :name AND id != :id;"_ns));
|
||||
IDB_DEBUG_TRY_UNWRAP(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store "
|
||||
"WHERE name = :name AND id != :id;"_ns));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(stmt->BindStringByIndex(0, mNewName));
|
||||
|
||||
@ -19558,7 +19569,7 @@ nsresult CreateIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// we should have thrown an error long before now...
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_DEBUG_TRY_VAR(
|
||||
IDB_DEBUG_TRY_UNWRAP(
|
||||
const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
@ -19706,10 +19717,11 @@ CreateIndexOp::UpdateIndexDataValuesFunction::OnFunctionCall(
|
||||
}
|
||||
#endif
|
||||
|
||||
IDB_TRY_VAR(auto cloneInfo, GetStructuredCloneReadInfoFromValueArray(
|
||||
aValues,
|
||||
/* aDataIndex */ 3,
|
||||
/* aFileIdsIndex */ 2, *mOp->mFileManager));
|
||||
IDB_TRY_UNWRAP(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromValueArray(aValues,
|
||||
/* aDataIndex */ 3,
|
||||
/* aFileIdsIndex */ 2,
|
||||
*mOp->mFileManager));
|
||||
|
||||
const IndexMetadata& metadata = mOp->mMetadata;
|
||||
const IndexOrObjectStoreId& objectStoreId = mOp->mObjectStoreId;
|
||||
@ -19776,7 +19788,7 @@ CreateIndexOp::UpdateIndexDataValuesFunction::OnFunctionCall(
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto indexValues, ReadCompressedIndexDataValues(*aValues, 1));
|
||||
IDB_TRY_UNWRAP(auto indexValues, ReadCompressedIndexDataValues(*aValues, 1));
|
||||
|
||||
const bool hadPreviousIndexValues = !indexValues.IsEmpty();
|
||||
|
||||
@ -19796,8 +19808,8 @@ CreateIndexOp::UpdateIndexDataValuesFunction::OnFunctionCall(
|
||||
fallible));
|
||||
}
|
||||
|
||||
IDB_TRY_VAR((auto [indexValuesBlob, indexValuesBlobLength]),
|
||||
MakeCompressedIndexDataValues(indexValues));
|
||||
IDB_TRY_UNWRAP((auto [indexValuesBlob, indexValuesBlobLength]),
|
||||
MakeCompressedIndexDataValues(indexValues));
|
||||
|
||||
MOZ_ASSERT(!indexValuesBlobLength == !(indexValuesBlob.get()));
|
||||
|
||||
@ -19935,11 +19947,11 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// Make sure |mIsLastIndex| is telling the truth.
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_DEBUG_TRY_VAR(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT id "
|
||||
"FROM object_store_index "
|
||||
"WHERE object_store_id = :object_store_id;"_ns));
|
||||
IDB_DEBUG_TRY_UNWRAP(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT id "
|
||||
"FROM object_store_index "
|
||||
"WHERE object_store_id = :object_store_id;"_ns));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(stmt->BindInt64ByIndex(0, mObjectStoreId));
|
||||
|
||||
@ -19985,8 +19997,8 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// mozStorage warns that these statements trigger a sort operation but we
|
||||
// don't care because this is a very rare call and we expect it to be slow.
|
||||
// The cost of having an index on this field is too high.
|
||||
IDB_TRY_VAR(
|
||||
const auto selectStmt,
|
||||
IDB_TRY_INSPECT(
|
||||
const auto& selectStmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
mUnique
|
||||
? (mIsLastIndex
|
||||
@ -20098,7 +20110,7 @@ nsresult DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
|
||||
// Now delete the index row.
|
||||
if (!deleteIndexRowStmt) {
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
deleteIndexRowStmt,
|
||||
aConnection->GetCachedStatement(
|
||||
mUnique ? "DELETE FROM unique_index_data "
|
||||
@ -20189,13 +20201,13 @@ nsresult RenameIndexOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
// thrown an error long before now...
|
||||
// The parameter names are not used, parameters are bound by index only
|
||||
// locally in the same function.
|
||||
IDB_DEBUG_TRY_VAR(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store_index "
|
||||
"WHERE object_store_id = :object_store_id "
|
||||
"AND name = :name "
|
||||
"AND id != :id;"_ns));
|
||||
IDB_DEBUG_TRY_UNWRAP(const auto stmt,
|
||||
aConnection->BorrowCachedStatement(
|
||||
"SELECT name "
|
||||
"FROM object_store_index "
|
||||
"WHERE object_store_id = :object_store_id "
|
||||
"AND name = :name "
|
||||
"AND id != :id;"_ns));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(stmt->BindInt64ByIndex(0, mObjectStoreId));
|
||||
|
||||
@ -20486,8 +20498,8 @@ nsresult ObjectStoreAddOrPutRequestOp::RemoveOldIndexDataValues(
|
||||
return rv;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*indexValuesStmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*indexValuesStmt, ExecuteStep));
|
||||
|
||||
if (hasResult) {
|
||||
IndexDataValuesAutoArray existingIndexValues;
|
||||
@ -20541,7 +20553,7 @@ bool ObjectStoreAddOrPutRequestOp::Init(TransactionBase& aTransaction) {
|
||||
mUniqueIndexTable.ref().MarkImmutable();
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
mStoredFileInfos,
|
||||
TransformIntoNewArray(
|
||||
mParams.fileAddInfos(),
|
||||
@ -21013,9 +21025,10 @@ Result<T, nsresult> ObjectStoreGetRequestOp::ConvertResponse(
|
||||
result.hasPreprocessInfo() = aInfo.HasPreprocessInfo();
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(result.files(), SerializeStructuredCloneFiles(
|
||||
mBackgroundParent, mDatabase, aInfo.Files(),
|
||||
std::is_same_v<T, PreprocessInfo>));
|
||||
IDB_TRY_UNWRAP(
|
||||
result.files(),
|
||||
SerializeStructuredCloneFiles(mBackgroundParent, mDatabase, aInfo.Files(),
|
||||
std::is_same_v<T, PreprocessInfo>));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -21056,9 +21069,9 @@ nsresult ObjectStoreGetRequestOp::DoDatabaseWork(
|
||||
IDB_TRY(CollectWhileHasResult(
|
||||
*stmt,
|
||||
[this](auto& stmt) mutable -> mozilla::Result<mozilla::Ok, nsresult> {
|
||||
IDB_TRY_VAR(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
&stmt, 1, 0, mDatabase->GetFileManager()));
|
||||
IDB_TRY_UNWRAP(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
&stmt, 1, 0, mDatabase->GetFileManager()));
|
||||
|
||||
if (cloneInfo.HasPreprocessInfo()) {
|
||||
mPreprocessInfoCount++;
|
||||
@ -21107,8 +21120,8 @@ ObjectStoreGetRequestOp::GetPreprocessParams() {
|
||||
|
||||
auto params = ObjectStoreGetPreprocessParams();
|
||||
|
||||
IDB_TRY_VAR(params.preprocessInfo(),
|
||||
ConvertResponse<PreprocessInfo>(std::move(mResponse[0])));
|
||||
IDB_TRY_UNWRAP(params.preprocessInfo(),
|
||||
ConvertResponse<PreprocessInfo>(std::move(mResponse[0])));
|
||||
|
||||
return PreprocessParams{std::move(params)};
|
||||
}
|
||||
@ -21122,7 +21135,7 @@ void ObjectStoreGetRequestOp::GetResponse(RequestResponse& aResponse,
|
||||
*aResponseSize = 0;
|
||||
|
||||
if (!mResponse.IsEmpty()) {
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
aResponse.get_ObjectStoreGetAllResponse().cloneInfos(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
std::make_move_iterator(mResponse.begin()),
|
||||
@ -21147,11 +21160,11 @@ void ObjectStoreGetRequestOp::GetResponse(RequestResponse& aResponse,
|
||||
aResponse.get_ObjectStoreGetResponse().cloneInfo();
|
||||
|
||||
*aResponseSize += mResponse[0].Size();
|
||||
IDB_TRY_VAR(serializedInfo,
|
||||
ConvertResponse<SerializedStructuredCloneReadInfo>(
|
||||
std::move(mResponse[0])),
|
||||
QM_VOID,
|
||||
[&aResponse](const nsresult result) { aResponse = result; });
|
||||
IDB_TRY_UNWRAP(serializedInfo,
|
||||
ConvertResponse<SerializedStructuredCloneReadInfo>(
|
||||
std::move(mResponse[0])),
|
||||
QM_VOID,
|
||||
[&aResponse](const nsresult result) { aResponse = result; });
|
||||
}
|
||||
}
|
||||
|
||||
@ -21425,7 +21438,8 @@ nsresult ObjectStoreCountRequestOp::DoDatabaseWork(
|
||||
}
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
MOZ_ASSERT(false, "This should never be possible!");
|
||||
@ -21577,9 +21591,9 @@ nsresult IndexGetRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
IDB_TRY(CollectWhileHasResult(
|
||||
*stmt,
|
||||
[this](auto& stmt) mutable -> mozilla::Result<mozilla::Ok, nsresult> {
|
||||
IDB_TRY_VAR(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
&stmt, 1, 0, mDatabase->GetFileManager()));
|
||||
IDB_TRY_UNWRAP(auto cloneInfo,
|
||||
GetStructuredCloneReadInfoFromStatement(
|
||||
&stmt, 1, 0, mDatabase->GetFileManager()));
|
||||
|
||||
if (cloneInfo.HasPreprocessInfo()) {
|
||||
IDB_WARNING("Preprocessing for indexes not yet implemented!");
|
||||
@ -21608,9 +21622,9 @@ void IndexGetRequestOp::GetResponse(RequestResponse& aResponse,
|
||||
|
||||
result.data().data = info.ReleaseData();
|
||||
|
||||
IDB_TRY_VAR(result.files(),
|
||||
SerializeStructuredCloneFiles(mBackgroundParent, mDatabase,
|
||||
info.Files(), false));
|
||||
IDB_TRY_UNWRAP(result.files(),
|
||||
SerializeStructuredCloneFiles(mBackgroundParent, mDatabase,
|
||||
info.Files(), false));
|
||||
|
||||
return result;
|
||||
};
|
||||
@ -21620,18 +21634,18 @@ void IndexGetRequestOp::GetResponse(RequestResponse& aResponse,
|
||||
*aResponseSize = 0;
|
||||
|
||||
if (!mResponse.IsEmpty()) {
|
||||
IDB_TRY_VAR(aResponse.get_IndexGetAllResponse().cloneInfos(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
std::make_move_iterator(mResponse.begin()),
|
||||
std::make_move_iterator(mResponse.end()),
|
||||
[convertResponse,
|
||||
&aResponseSize](StructuredCloneReadInfoParent&& info) {
|
||||
*aResponseSize += info.Size();
|
||||
return convertResponse(std::move(info));
|
||||
},
|
||||
fallible),
|
||||
QM_VOID,
|
||||
[&aResponse](const nsresult result) { aResponse = result; });
|
||||
IDB_TRY_UNWRAP(
|
||||
aResponse.get_IndexGetAllResponse().cloneInfos(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
std::make_move_iterator(mResponse.begin()),
|
||||
std::make_move_iterator(mResponse.end()),
|
||||
[convertResponse,
|
||||
&aResponseSize](StructuredCloneReadInfoParent&& info) {
|
||||
*aResponseSize += info.Size();
|
||||
return convertResponse(std::move(info));
|
||||
},
|
||||
fallible),
|
||||
QM_VOID, [&aResponse](const nsresult result) { aResponse = result; });
|
||||
}
|
||||
|
||||
return;
|
||||
@ -21645,9 +21659,9 @@ void IndexGetRequestOp::GetResponse(RequestResponse& aResponse,
|
||||
aResponse.get_IndexGetResponse().cloneInfo();
|
||||
|
||||
*aResponseSize += mResponse[0].Size();
|
||||
IDB_TRY_VAR(serializedInfo, convertResponse(std::move(mResponse[0])),
|
||||
QM_VOID,
|
||||
[&aResponse](const nsresult result) { aResponse = result; });
|
||||
IDB_TRY_UNWRAP(serializedInfo, convertResponse(std::move(mResponse[0])),
|
||||
QM_VOID,
|
||||
[&aResponse](const nsresult result) { aResponse = result; });
|
||||
}
|
||||
}
|
||||
|
||||
@ -21783,7 +21797,8 @@ nsresult IndexCountRequestOp::DoDatabaseWork(DatabaseConnection* aConnection) {
|
||||
}
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
MOZ_ASSERT(false, "This should never be possible!");
|
||||
@ -21950,8 +21965,8 @@ void CursorOpBaseHelperBase<CursorType>::PopulateExtraResponses(
|
||||
// any remaining entries, and signal overall success. Probably, future
|
||||
// attempts to access the same entry will fail as well, but it might never
|
||||
// be accessed by the application.
|
||||
IDB_TRY_VAR(
|
||||
const auto responseSize,
|
||||
IDB_TRY_INSPECT(
|
||||
const auto& responseSize,
|
||||
PopulateResponseFromStatement(aStmt, false, aOptPreviousSortKey),
|
||||
extraCount, [](const auto&) {
|
||||
// TODO: Maybe disable preloading for this cursor? The problem will
|
||||
@ -22157,7 +22172,8 @@ void IndexOpenOpHelper<CursorType>::PrepareIndexKeyConditionClause(
|
||||
template <IDBCursorType CursorType>
|
||||
nsresult CommonOpenOpHelper<CursorType>::ProcessStatementSteps(
|
||||
mozIStorageStatement* const aStmt) {
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(aStmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(aStmt, ExecuteStep));
|
||||
|
||||
if (!hasResult) {
|
||||
SetResponse(void_t{});
|
||||
@ -22649,8 +22665,8 @@ nsresult Cursor<CursorType>::ContinueOp::DoDatabaseWork(
|
||||
// TODO: Why do we query the records we don't need and skip them here, rather
|
||||
// than using a OFFSET clause in the query?
|
||||
for (uint32_t index = 0; index < advanceCount; index++) {
|
||||
IDB_TRY_VAR(const bool hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(&*stmt, ExecuteStep));
|
||||
|
||||
if (!hasResult) {
|
||||
mResponse = void_t();
|
||||
|
@ -239,15 +239,16 @@ nsresult ReadCompressedIndexDataValuesFromBlob(
|
||||
NS_ERROR_FILE_CORRUPTED, IDB_REPORT_INTERNAL_ERR_LAMBDA);
|
||||
|
||||
for (auto remainder = aBlobData; !remainder.IsEmpty();) {
|
||||
IDB_TRY_VAR((const auto [indexId, unique, remainderAfterIndexId]),
|
||||
ReadCompressedIndexId(remainder));
|
||||
IDB_TRY_INSPECT((const auto& [indexId, unique, remainderAfterIndexId]),
|
||||
ReadCompressedIndexId(remainder));
|
||||
|
||||
IDB_TRY(OkIf(!remainderAfterIndexId.IsEmpty()), NS_ERROR_FILE_CORRUPTED,
|
||||
IDB_REPORT_INTERNAL_ERR_LAMBDA);
|
||||
|
||||
// Read key buffer length.
|
||||
IDB_TRY_VAR((const auto [keyBufferLength, remainderAfterKeyBufferLength]),
|
||||
ReadCompressedNumber(remainderAfterIndexId));
|
||||
IDB_TRY_INSPECT(
|
||||
(const auto& [keyBufferLength, remainderAfterKeyBufferLength]),
|
||||
ReadCompressedNumber(remainderAfterIndexId));
|
||||
|
||||
IDB_TRY(OkIf(!remainderAfterKeyBufferLength.IsEmpty()),
|
||||
NS_ERROR_FILE_CORRUPTED, IDB_REPORT_INTERNAL_ERR_LAMBDA);
|
||||
@ -365,7 +366,8 @@ GetStructuredCloneReadInfoFromBlob(const uint8_t* aBlobData,
|
||||
|
||||
nsTArray<StructuredCloneFileParent> files;
|
||||
if (!aFileIds.IsVoid()) {
|
||||
IDB_TRY_VAR(files, DeserializeStructuredCloneFiles(aFileManager, aFileIds));
|
||||
IDB_TRY_UNWRAP(files,
|
||||
DeserializeStructuredCloneFiles(aFileManager, aFileIds));
|
||||
}
|
||||
|
||||
return StructuredCloneReadInfoParent{std::move(data), std::move(files),
|
||||
@ -382,7 +384,8 @@ GetStructuredCloneReadInfoFromExternalBlob(uint64_t aIntData,
|
||||
|
||||
nsTArray<StructuredCloneFileParent> files;
|
||||
if (!aFileIds.IsVoid()) {
|
||||
IDB_TRY_VAR(files, DeserializeStructuredCloneFiles(aFileManager, aFileIds));
|
||||
IDB_TRY_UNWRAP(files,
|
||||
DeserializeStructuredCloneFiles(aFileManager, aFileIds));
|
||||
}
|
||||
|
||||
// Higher and lower 32 bits described
|
||||
@ -419,8 +422,8 @@ GetStructuredCloneReadInfoFromExternalBlob(uint64_t aIntData,
|
||||
do {
|
||||
char buffer[kFileCopyBufferSize];
|
||||
|
||||
IDB_TRY_VAR(
|
||||
const uint32_t numRead,
|
||||
IDB_TRY_INSPECT(
|
||||
const uint32_t& numRead,
|
||||
MOZ_TO_RESULT_INVOKE(snappyInputStream, Read, buffer, sizeof(buffer)));
|
||||
|
||||
if (!numRead) {
|
||||
@ -625,7 +628,8 @@ Result<IndexDataValuesAutoArray, nsresult> ReadCompressedIndexDataValues(
|
||||
|
||||
Result<std::tuple<IndexOrObjectStoreId, bool, Span<const uint8_t>>, nsresult>
|
||||
ReadCompressedIndexId(const Span<const uint8_t> aData) {
|
||||
IDB_TRY_VAR((const auto [indexId, remainder]), ReadCompressedNumber(aData));
|
||||
IDB_TRY_INSPECT((const auto& [indexId, remainder]),
|
||||
ReadCompressedNumber(aData));
|
||||
|
||||
MOZ_ASSERT(UINT64_MAX / 2 >= uint64_t(indexId), "Bad index id!");
|
||||
|
||||
@ -689,8 +693,8 @@ DeserializeStructuredCloneFiles(const FileManager& aFileManager,
|
||||
const auto& token = tokenizer.nextToken();
|
||||
MOZ_ASSERT(!token.IsEmpty());
|
||||
|
||||
IDB_TRY_VAR(auto structuredCloneFile,
|
||||
DeserializeStructuredCloneFile(aFileManager, token));
|
||||
IDB_TRY_UNWRAP(auto structuredCloneFile,
|
||||
DeserializeStructuredCloneFile(aFileManager, token));
|
||||
|
||||
result.EmplaceBack(std::move(structuredCloneFile));
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ nsresult IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
|
||||
return NS_OK;
|
||||
|
||||
case PrincipalInfo::TContentPrincipalInfo: {
|
||||
IDB_TRY_VAR(auto principal, PrincipalInfoToPrincipal(*principalInfo));
|
||||
IDB_TRY_UNWRAP(auto principal, PrincipalInfoToPrincipal(*principalInfo));
|
||||
|
||||
nsresult rv = QuotaManager::GetInfoFromPrincipal(principal, nullptr,
|
||||
nullptr, &aOrigin);
|
||||
|
@ -826,7 +826,7 @@ RefPtr<IDBRequest> IDBObjectStore::AddOrPut(JSContext* aCx,
|
||||
commonParams.indexUpdateInfos() = std::move(updateInfos);
|
||||
|
||||
// Convert any blobs or mutable files into FileAddInfo.
|
||||
IDB_TRY_VAR(
|
||||
IDB_TRY_UNWRAP(
|
||||
commonParams.fileAddInfos(),
|
||||
TransformIntoNewArrayAbortOnErr(
|
||||
cloneWriteInfo.mFiles,
|
||||
|
@ -24,13 +24,13 @@
|
||||
#define IDB_TRY_VAR_GLUE(accessFunction, ...) \
|
||||
QM_TRY_VAR_META(mozilla::dom::indexedDB, MOZ_UNIQUE_VAR(tryResult), \
|
||||
accessFunction, ##__VA_ARGS__)
|
||||
#define IDB_TRY_VAR(...) IDB_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define IDB_TRY_UNWRAP(...) IDB_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define IDB_TRY_INSPECT(...) IDB_TRY_VAR_GLUE(inspect, __VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
# define IDB_DEBUG_TRY_VAR(...) IDB_TRY_VAR(__VA_ARGS__)
|
||||
# define IDB_DEBUG_TRY_UNWRAP(...) IDB_TRY_UNWRAP(__VA_ARGS__)
|
||||
#else
|
||||
# define IDB_DEBUG_TRY_VAR(...)
|
||||
# define IDB_DEBUG_TRY_UNWRAP(...)
|
||||
#endif
|
||||
|
||||
// IndexedDB equivalents of QM_TRY_RETURN and QM_DEBUG_TRY_RETURN.
|
||||
|
@ -527,7 +527,8 @@ bool IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx,
|
||||
return false;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto factory, IDBFactory::CreateForMainThreadJS(global), false);
|
||||
IDB_TRY_UNWRAP(auto factory, IDBFactory::CreateForMainThreadJS(global),
|
||||
false);
|
||||
|
||||
MOZ_ASSERT(factory, "This should never fail for chrome!");
|
||||
|
||||
|
@ -107,7 +107,8 @@ nsresult UpgradeSchemaFrom4To5(mozIStorageConnection& aConnection) {
|
||||
{
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
|
||||
IDB_TRY_VAR(const bool hasResults, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResults,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
|
||||
if (NS_WARN_IF(!hasResults)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1447,7 +1448,7 @@ UpgradeSchemaFrom17_0To18_0Helper::InsertIndexDataValuesFunction::
|
||||
|
||||
// Read out the previous value. It may be NULL, in which case we'll just end
|
||||
// up with an empty array.
|
||||
IDB_TRY_VAR(auto indexValues, ReadCompressedIndexDataValues(*aValues, 0));
|
||||
IDB_TRY_UNWRAP(auto indexValues, ReadCompressedIndexDataValues(*aValues, 0));
|
||||
|
||||
IndexOrObjectStoreId indexId;
|
||||
nsresult rv = aValues->GetInt64(1, &indexId);
|
||||
@ -1475,8 +1476,8 @@ UpgradeSchemaFrom17_0To18_0Helper::InsertIndexDataValuesFunction::
|
||||
}
|
||||
|
||||
// Compress the array.
|
||||
IDB_TRY_VAR((auto [indexValuesBlob, indexValuesBlobLength]),
|
||||
MakeCompressedIndexDataValues(indexValues));
|
||||
IDB_TRY_UNWRAP((auto [indexValuesBlob, indexValuesBlobLength]),
|
||||
MakeCompressedIndexDataValues(indexValues));
|
||||
|
||||
// The compressed blob is the result of this function.
|
||||
nsCOMPtr<nsIVariant> result = new storage::AdoptedBlobVariant(
|
||||
@ -2300,7 +2301,8 @@ nsresult UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory,
|
||||
{
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
|
||||
IDB_TRY_VAR(const bool hasResult, MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
IDB_TRY_INSPECT(const bool& hasResult,
|
||||
MOZ_TO_RESULT_INVOKE(stmt, ExecuteStep));
|
||||
|
||||
if (NS_WARN_IF(!hasResult)) {
|
||||
MOZ_ASSERT(false, "This should never be possible!");
|
||||
@ -2412,8 +2414,8 @@ UpgradeIndexDataValuesFunction::ReadOldCompressedIDVFromBlob(
|
||||
IndexDataValuesArray result;
|
||||
for (auto remainder = aBlobData; !remainder.IsEmpty();) {
|
||||
if (!nextIndexIdAlreadyRead) {
|
||||
IDB_TRY_VAR((std::tie(indexId, unique, remainder)),
|
||||
ReadCompressedIndexId(remainder));
|
||||
IDB_TRY_UNWRAP((std::tie(indexId, unique, remainder)),
|
||||
ReadCompressedIndexId(remainder));
|
||||
}
|
||||
nextIndexIdAlreadyRead = false;
|
||||
|
||||
@ -2505,8 +2507,8 @@ UpgradeIndexDataValuesFunction::OnFunctionCall(
|
||||
IDB_TRY_INSPECT(const auto& oldIdv,
|
||||
ReadOldCompressedIDVFromBlob(Span(oldBlob, oldBlobLength)));
|
||||
|
||||
IDB_TRY_VAR((auto [newIdv, newIdvLength]),
|
||||
MakeCompressedIndexDataValues(oldIdv));
|
||||
IDB_TRY_UNWRAP((auto [newIdv, newIdvLength]),
|
||||
MakeCompressedIndexDataValues(oldIdv));
|
||||
|
||||
nsCOMPtr<nsIVariant> result = new storage::AdoptedBlobVariant(
|
||||
std::pair(newIdv.release(), newIdvLength));
|
||||
@ -2884,8 +2886,8 @@ UpgradeFileIdsFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(auto cloneInfo, GetStructuredCloneReadInfoFromValueArray(
|
||||
aArguments, 1, 0, *mFileManager));
|
||||
IDB_TRY_UNWRAP(auto cloneInfo, GetStructuredCloneReadInfoFromValueArray(
|
||||
aArguments, 1, 0, *mFileManager));
|
||||
|
||||
nsAutoString fileIds;
|
||||
// XXX does this really need non-const cloneInfo?
|
||||
@ -2991,8 +2993,8 @@ Result<bool, nsresult> MaybeUpgradeSchema(mozIStorageConnection& aConnection,
|
||||
});
|
||||
}
|
||||
|
||||
IDB_TRY_VAR(schemaVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
IDB_TRY_UNWRAP(schemaVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(schemaVersion == kSQLiteSchemaVersion);
|
||||
|
@ -4257,8 +4257,8 @@ nsresult Connection::EnsureStorageConnection() {
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
if (!mDatabaseWasNotAvailable || mHasCreatedDatabase) {
|
||||
LS_TRY_VAR(auto directoryEntry, quotaManager->GetDirectoryForOrigin(
|
||||
PERSISTENCE_TYPE_DEFAULT, mOrigin));
|
||||
LS_TRY_UNWRAP(auto directoryEntry, quotaManager->GetDirectoryForOrigin(
|
||||
PERSISTENCE_TYPE_DEFAULT, mOrigin));
|
||||
|
||||
rv = directoryEntry->Append(
|
||||
NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
|
||||
@ -7346,8 +7346,8 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
LS_TRY_VAR(directoryEntry, quotaManager->GetDirectoryForOrigin(
|
||||
PERSISTENCE_TYPE_DEFAULT, mOrigin));
|
||||
LS_TRY_UNWRAP(directoryEntry, quotaManager->GetDirectoryForOrigin(
|
||||
PERSISTENCE_TYPE_DEFAULT, mOrigin));
|
||||
|
||||
quotaManager->EnsureQuotaForOrigin(PERSISTENCE_TYPE_DEFAULT, mGroup,
|
||||
mOrigin);
|
||||
@ -8797,8 +8797,8 @@ Result<UsageInfo, nsresult> QuotaClient::InitOrigin(
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
LS_TRY_VAR(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
LS_TRY_UNWRAP(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
|
||||
MOZ_ASSERT(directory);
|
||||
|
||||
|
@ -203,13 +203,13 @@
|
||||
#define LS_TRY_VAR_GLUE(accessFunction, ...) \
|
||||
QM_TRY_VAR_META(mozilla::dom::localstorage, MOZ_UNIQUE_VAR(tryResult), \
|
||||
accessFunction, ##__VA_ARGS__)
|
||||
#define LS_TRY_VAR(...) LS_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define LS_TRY_UNWRAP(...) LS_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define LS_TRY_INSPECT(...) LS_TRY_VAR_GLUE(inspect, __VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
# define LS_DEBUG_TRY_VAR(...) LS_TRY_VAR(__VA_ARGS__)
|
||||
# define LS_DEBUG_TRY_UNWRAP(...) LS_TRY_UNWRAP(__VA_ARGS__)
|
||||
#else
|
||||
# define LS_DEBUG_TRY_VAR(...)
|
||||
# define LS_DEBUG_TRY_UNWRAP(...)
|
||||
#endif
|
||||
|
||||
// LocalStorage equivalents of QM_TRY_RETURN and QM_DEBUG_TRY_RETURN.
|
||||
|
@ -2517,7 +2517,7 @@ Result<nsCOMPtr<nsIOutputStream>, nsresult> GetOutputStream(
|
||||
|
||||
Result<nsCOMPtr<nsIBinaryOutputStream>, nsresult> GetBinaryOutputStream(
|
||||
nsIFile& aFile, FileFlag aFileFlag) {
|
||||
QM_TRY_VAR(auto outputStream, GetOutputStream(aFile, aFileFlag));
|
||||
QM_TRY_UNWRAP(auto outputStream, GetOutputStream(aFile, aFileFlag));
|
||||
|
||||
QM_TRY(OkIf(outputStream), Err(NS_ERROR_UNEXPECTED));
|
||||
|
||||
@ -2572,12 +2572,12 @@ nsresult CreateDirectoryMetadata(nsIFile& aDirectory, int64_t aTimestamp,
|
||||
|
||||
MOZ_ASSERT(groupPrefix == originPrefix);
|
||||
|
||||
QM_TRY_VAR(auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||
QM_TRY_UNWRAP(auto file, MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aDirectory, Clone));
|
||||
|
||||
QM_TRY(file->Append(nsLiteralString(METADATA_TMP_FILE_NAME)));
|
||||
|
||||
QM_TRY_VAR(auto stream, GetBinaryOutputStream(*file, kTruncateFileFlag));
|
||||
QM_TRY_UNWRAP(auto stream, GetBinaryOutputStream(*file, kTruncateFileFlag));
|
||||
|
||||
MOZ_ASSERT(stream);
|
||||
|
||||
@ -2605,12 +2605,12 @@ nsresult CreateDirectoryMetadata2(nsIFile& aDirectory, int64_t aTimestamp,
|
||||
const nsACString& aOrigin) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
QM_TRY_VAR(auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||
QM_TRY_UNWRAP(auto file, MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aDirectory, Clone));
|
||||
|
||||
QM_TRY(file->Append(nsLiteralString(METADATA_V2_TMP_FILE_NAME)));
|
||||
|
||||
QM_TRY_VAR(auto stream, GetBinaryOutputStream(*file, kTruncateFileFlag));
|
||||
QM_TRY_UNWRAP(auto stream, GetBinaryOutputStream(*file, kTruncateFileFlag));
|
||||
|
||||
MOZ_ASSERT(stream);
|
||||
|
||||
@ -2649,8 +2649,8 @@ Result<nsCOMPtr<nsIBinaryInputStream>, nsresult> GetBinaryInputStream(
|
||||
nsIFile& aDirectory, const nsAString& aFilename) {
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
QM_TRY_VAR(auto file,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>, aDirectory, Clone));
|
||||
QM_TRY_UNWRAP(auto file, MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aDirectory, Clone));
|
||||
|
||||
QM_TRY(file->Append(aFilename));
|
||||
|
||||
@ -4373,8 +4373,8 @@ nsresult QuotaManager::LoadQuota() {
|
||||
}
|
||||
|
||||
if (accessed) {
|
||||
QM_TRY_VAR(auto directory,
|
||||
GetDirectoryForOrigin(persistenceType, origin));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
GetDirectoryForOrigin(persistenceType, origin));
|
||||
|
||||
bool exists;
|
||||
rv = directory->Exists(&exists);
|
||||
@ -4656,8 +4656,8 @@ already_AddRefed<QuotaObject> QuotaManager::GetQuotaObject(
|
||||
QM_TRY(aFile->GetPath(path), nullptr);
|
||||
|
||||
#ifdef DEBUG
|
||||
QM_TRY_VAR(auto directory, GetDirectoryForOrigin(aPersistenceType, aOrigin),
|
||||
nullptr);
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
GetDirectoryForOrigin(aPersistenceType, aOrigin), nullptr);
|
||||
|
||||
nsAutoString clientType;
|
||||
bool ok = Client::TypeToText(aClientType, clientType, fallible);
|
||||
@ -4829,7 +4829,8 @@ void QuotaManager::AbortOperationsForProcess(ContentParentId aContentParentId) {
|
||||
|
||||
Result<nsCOMPtr<nsIFile>, nsresult> QuotaManager::GetDirectoryForOrigin(
|
||||
PersistenceType aPersistenceType, const nsACString& aASCIIOrigin) const {
|
||||
QM_TRY_VAR(auto directory, QM_NewLocalFile(GetStoragePath(aPersistenceType)));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
QM_NewLocalFile(GetStoragePath(aPersistenceType)));
|
||||
|
||||
nsAutoCString originSanitized(aASCIIOrigin);
|
||||
SanitizeOriginString(originSanitized);
|
||||
@ -4865,9 +4866,9 @@ nsresult QuotaManager::GetDirectoryMetadata2(
|
||||
MOZ_ASSERT(aPersisted);
|
||||
MOZ_ASSERT(mStorageConnection);
|
||||
|
||||
QM_TRY_VAR(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
QM_TRY_UNWRAP(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
|
||||
QM_TRY_INSPECT(const uint64_t& timestamp,
|
||||
MOZ_TO_RESULT_INVOKE(binaryStream, Read64));
|
||||
@ -4886,8 +4887,8 @@ nsresult QuotaManager::GetDirectoryMetadata2(
|
||||
QM_TRY_INSPECT(const auto& suffix, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCString, binaryStream, ReadCString));
|
||||
|
||||
QM_TRY_VAR(auto group,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream, ReadCString));
|
||||
QM_TRY_UNWRAP(auto group, MOZ_TO_RESULT_INVOKE_TYPED(nsCString, binaryStream,
|
||||
ReadCString));
|
||||
|
||||
QM_TRY_INSPECT(const auto& origin, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCString, binaryStream, ReadCString));
|
||||
@ -4953,9 +4954,9 @@ nsresult QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory,
|
||||
MOZ_ASSERT(aTimestamp != nullptr || aPersisted != nullptr);
|
||||
MOZ_ASSERT(mStorageConnection);
|
||||
|
||||
QM_TRY_VAR(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
QM_TRY_UNWRAP(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
|
||||
uint64_t timestamp;
|
||||
nsresult rv = binaryStream->Read64(×tamp);
|
||||
@ -5512,8 +5513,8 @@ nsresult QuotaManager::UpgradeStorage(const int32_t aOldVersion,
|
||||
MOZ_ASSERT(aConnection);
|
||||
|
||||
for (const PersistenceType persistenceType : kAllPersistenceTypes) {
|
||||
QM_TRY_VAR(auto directory,
|
||||
QM_NewLocalFile(GetStoragePath(persistenceType)));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
QM_NewLocalFile(GetStoragePath(persistenceType)));
|
||||
|
||||
QM_TRY_INSPECT(const bool& exists, MOZ_TO_RESULT_INVOKE(directory, Exists));
|
||||
|
||||
@ -5527,8 +5528,8 @@ nsresult QuotaManager::UpgradeStorage(const int32_t aOldVersion,
|
||||
}
|
||||
|
||||
{
|
||||
QM_DEBUG_TRY_VAR(const int32_t storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
QM_DEBUG_TRY_UNWRAP(const int32_t storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
|
||||
MOZ_ASSERT(storageVersion == aOldVersion);
|
||||
}
|
||||
@ -5700,8 +5701,8 @@ nsresult QuotaManager::UpgradeStorageFrom2_2To2_3(
|
||||
"VALUES (0)")));
|
||||
|
||||
{
|
||||
QM_DEBUG_TRY_VAR(const int32_t storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
QM_DEBUG_TRY_UNWRAP(const int32_t storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(aConnection, GetSchemaVersion));
|
||||
|
||||
MOZ_ASSERT(storageVersion == MakeStorageVersion(2, 2));
|
||||
}
|
||||
@ -6325,7 +6326,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
Initialization::Storage,
|
||||
[&self = *this] { return static_cast<bool>(self.mStorageConnection); });
|
||||
|
||||
QM_TRY_VAR(auto storageFile, QM_NewLocalFile(mBasePath));
|
||||
QM_TRY_UNWRAP(auto storageFile, QM_NewLocalFile(mBasePath));
|
||||
|
||||
QM_TRY(storageFile->Append(mStorageName + kSQLiteSuffix));
|
||||
|
||||
@ -6333,7 +6334,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
MOZ_TO_RESULT_INVOKE(storageFile, Exists));
|
||||
|
||||
if (!storageFileExists) {
|
||||
QM_TRY_VAR(auto indexedDBDir, QM_NewLocalFile(mIndexedDBPath));
|
||||
QM_TRY_UNWRAP(auto indexedDBDir, QM_NewLocalFile(mIndexedDBPath));
|
||||
|
||||
QM_TRY_INSPECT(const auto& indexedDBDirExists,
|
||||
MOZ_TO_RESULT_INVOKE(indexedDBDir, Exists));
|
||||
@ -6343,7 +6344,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
indexedDBDir));
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto persistentStorageDir, QM_NewLocalFile(mStoragePath));
|
||||
QM_TRY_UNWRAP(auto persistentStorageDir, QM_NewLocalFile(mStoragePath));
|
||||
|
||||
QM_TRY(persistentStorageDir->Append(
|
||||
nsLiteralString(PERSISTENT_DIRECTORY_NAME)));
|
||||
@ -6357,31 +6358,31 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
}
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto ss, ToResultGet<nsCOMPtr<mozIStorageService>>(
|
||||
MOZ_SELECT_OVERLOAD(do_GetService),
|
||||
MOZ_STORAGE_SERVICE_CONTRACTID));
|
||||
QM_TRY_UNWRAP(auto ss, ToResultGet<nsCOMPtr<mozIStorageService>>(
|
||||
MOZ_SELECT_OVERLOAD(do_GetService),
|
||||
MOZ_STORAGE_SERVICE_CONTRACTID));
|
||||
|
||||
QM_TRY_VAR(auto connection,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>, ss,
|
||||
OpenUnsharedDatabase, storageFile)
|
||||
.orElse(ErrToOkOrErr<NS_ERROR_FILE_CORRUPTED, nullptr,
|
||||
nsCOMPtr<mozIStorageConnection>>));
|
||||
QM_TRY_UNWRAP(auto connection,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>, ss,
|
||||
OpenUnsharedDatabase, storageFile)
|
||||
.orElse(ErrToOkOrErr<NS_ERROR_FILE_CORRUPTED, nullptr,
|
||||
nsCOMPtr<mozIStorageConnection>>));
|
||||
|
||||
if (!connection) {
|
||||
// Nuke the database file.
|
||||
QM_TRY(storageFile->Remove(false));
|
||||
|
||||
QM_TRY_VAR(connection,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<mozIStorageConnection>, ss,
|
||||
OpenUnsharedDatabase, storageFile));
|
||||
QM_TRY_UNWRAP(connection, MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageConnection>, ss,
|
||||
OpenUnsharedDatabase, storageFile));
|
||||
}
|
||||
|
||||
// We want extra durability for this important file.
|
||||
QM_TRY(connection->ExecuteSimpleSQL("PRAGMA synchronous = EXTRA;"_ns));
|
||||
|
||||
// Check to make sure that the storage version is correct.
|
||||
QM_TRY_VAR(auto storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
QM_TRY_UNWRAP(auto storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
|
||||
// Hacky downgrade logic!
|
||||
// If we see major.minor of 3.0, downgrade it to be 2.1.
|
||||
@ -6399,7 +6400,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
if (storageVersion < kStorageVersion) {
|
||||
const bool newDatabase = !storageVersion;
|
||||
|
||||
QM_TRY_VAR(auto storageDir, QM_NewLocalFile(mStoragePath));
|
||||
QM_TRY_UNWRAP(auto storageDir, QM_NewLocalFile(mStoragePath));
|
||||
|
||||
QM_TRY_INSPECT(const auto& storageDirExists,
|
||||
MOZ_TO_RESULT_INVOKE(storageDir, Exists));
|
||||
@ -6424,8 +6425,8 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
QM_TRY(CreateTables(connection));
|
||||
|
||||
{
|
||||
QM_DEBUG_TRY_VAR(const auto storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
QM_DEBUG_TRY_UNWRAP(const auto storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
MOZ_ASSERT(storageVersion == kStorageVersion);
|
||||
}
|
||||
|
||||
@ -6456,8 +6457,8 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
});
|
||||
}
|
||||
|
||||
QM_TRY_VAR(storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
QM_TRY_UNWRAP(storageVersion,
|
||||
MOZ_TO_RESULT_INVOKE(connection, GetSchemaVersion));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(storageVersion == kStorageVersion);
|
||||
@ -6467,8 +6468,8 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
}
|
||||
|
||||
if (CachedNextGenLocalStorageEnabled()) {
|
||||
QM_TRY_VAR((auto [connection, newlyCreatedOrRecreated]),
|
||||
CreateLocalStorageArchiveConnection());
|
||||
QM_TRY_UNWRAP((auto [connection, newlyCreatedOrRecreated]),
|
||||
CreateLocalStorageArchiveConnection());
|
||||
|
||||
uint32_t version = 0;
|
||||
|
||||
@ -6477,14 +6478,14 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
IsLocalStorageArchiveInitialized(*connection));
|
||||
|
||||
if (initialized) {
|
||||
QM_TRY_VAR(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
QM_TRY_UNWRAP(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
}
|
||||
}
|
||||
|
||||
if (version > kLocalStorageArchiveVersion) {
|
||||
QM_TRY(DowngradeLocalStorageArchive(connection));
|
||||
|
||||
QM_TRY_VAR(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
QM_TRY_UNWRAP(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
|
||||
MOZ_ASSERT(version == kLocalStorageArchiveVersion);
|
||||
} else if (version != kLocalStorageArchiveVersion) {
|
||||
@ -6512,7 +6513,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
});
|
||||
}
|
||||
|
||||
QM_TRY_VAR(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
QM_TRY_UNWRAP(version, LoadLocalStorageArchiveVersion(*connection));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(version == kLocalStorageArchiveVersion);
|
||||
@ -6524,7 +6525,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
|
||||
bool cacheUsable = true;
|
||||
|
||||
QM_TRY_VAR(int32_t cacheVersion, LoadCacheVersion(*connection));
|
||||
QM_TRY_UNWRAP(int32_t cacheVersion, LoadCacheVersion(*connection));
|
||||
|
||||
if (cacheVersion > kCacheVersion) {
|
||||
cacheUsable = false;
|
||||
@ -6555,7 +6556,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
if (insertStmt) {
|
||||
MOZ_ALWAYS_SUCCEEDS(insertStmt->Reset());
|
||||
} else {
|
||||
QM_TRY_VAR(
|
||||
QM_TRY_UNWRAP(
|
||||
insertStmt,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(
|
||||
nsCOMPtr<mozIStorageStatement>, connection, CreateStatement,
|
||||
@ -6586,7 +6587,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
|
||||
});
|
||||
}
|
||||
|
||||
QM_TRY_VAR(cacheVersion, LoadCacheVersion(*connection));
|
||||
QM_TRY_UNWRAP(cacheVersion, LoadCacheVersion(*connection));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(cacheVersion == kCacheVersion);
|
||||
@ -6757,8 +6758,8 @@ nsresult QuotaManager::EnsurePersistentOriginIsInitialized(
|
||||
info.mPersistentOriginAttempted = true;
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto directory,
|
||||
GetDirectoryForOrigin(PERSISTENCE_TYPE_PERSISTENT, aOrigin));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
GetDirectoryForOrigin(PERSISTENCE_TYPE_PERSISTENT, aOrigin));
|
||||
|
||||
if (mInitializedOrigins.Contains(aOrigin)) {
|
||||
directory.forget(aDirectory);
|
||||
@ -6834,7 +6835,8 @@ nsresult QuotaManager::EnsureTemporaryOriginIsInitialized(
|
||||
}
|
||||
|
||||
// Get directory for this origin and persistence type.
|
||||
QM_TRY_VAR(auto directory, GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
|
||||
bool created;
|
||||
rv = EnsureOriginDirectory(directory, &created);
|
||||
@ -7626,8 +7628,8 @@ void QuotaManager::CheckTemporaryStorageLimits() {
|
||||
|
||||
void QuotaManager::DeleteFilesForOrigin(PersistenceType aPersistenceType,
|
||||
const nsACString& aOrigin) {
|
||||
QM_TRY_VAR(auto directory, GetDirectoryForOrigin(aPersistenceType, aOrigin),
|
||||
QM_VOID);
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
GetDirectoryForOrigin(aPersistenceType, aOrigin), QM_VOID);
|
||||
|
||||
nsresult rv = directory->Remove(true);
|
||||
if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
|
||||
@ -8339,16 +8341,16 @@ nsresult SaveOriginAccessTimeOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
||||
|
||||
AUTO_PROFILER_LABEL("SaveOriginAccessTimeOp::DoDirectoryWork", OTHER);
|
||||
|
||||
QM_TRY_VAR(auto file,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
QM_TRY_UNWRAP(auto file,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
|
||||
nsresult rv = file->Append(nsLiteralString(METADATA_V2_FILE_NAME));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto stream, GetBinaryOutputStream(*file, kUpdateFileFlag));
|
||||
QM_TRY_UNWRAP(auto stream, GetBinaryOutputStream(*file, kUpdateFileFlag));
|
||||
|
||||
// The origin directory may not exist anymore.
|
||||
if (stream) {
|
||||
@ -8918,8 +8920,8 @@ Result<UsageInfo, nsresult> QuotaUsageRequestBase::GetUsageForOrigin(
|
||||
const nsACString& aGroup, const nsACString& aOrigin) {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
QM_TRY_VAR(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
|
||||
bool exists;
|
||||
nsresult rv = directory->Exists(&exists);
|
||||
@ -9984,9 +9986,9 @@ nsresult PersistedOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
||||
// If we get here, it means the origin hasn't been initialized yet.
|
||||
// Try to get the persisted flag from directory metadata on disk.
|
||||
|
||||
QM_TRY_VAR(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
|
||||
bool exists;
|
||||
nsresult rv = directory->Exists(&exists);
|
||||
@ -10039,9 +10041,9 @@ nsresult PersistOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
||||
|
||||
// Update directory metadata on disk first. Then, create/update the originInfo
|
||||
// if needed.
|
||||
QM_TRY_VAR(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
QM_TRY_UNWRAP(auto directory,
|
||||
aQuotaManager.GetDirectoryForOrigin(mPersistenceType.Value(),
|
||||
mOriginScope.GetOrigin()));
|
||||
|
||||
bool created;
|
||||
nsresult rv = aQuotaManager.EnsureOriginDirectory(directory, &created);
|
||||
@ -10090,7 +10092,7 @@ nsresult PersistOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto stream, GetBinaryOutputStream(*file, kUpdateFileFlag));
|
||||
QM_TRY_UNWRAP(auto stream, GetBinaryOutputStream(*file, kUpdateFileFlag));
|
||||
|
||||
MOZ_ASSERT(stream);
|
||||
|
||||
@ -10387,8 +10389,8 @@ nsresult StorageOperationBase::GetDirectoryMetadata(nsIFile* aDirectory,
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(aDirectory);
|
||||
|
||||
QM_TRY_VAR(
|
||||
auto binaryStream,
|
||||
QM_TRY_INSPECT(
|
||||
const auto& binaryStream,
|
||||
GetBinaryInputStream(*aDirectory, nsLiteralString(METADATA_FILE_NAME)));
|
||||
|
||||
QM_TRY_INSPECT(const uint64_t& timestamp,
|
||||
@ -10419,9 +10421,9 @@ nsresult StorageOperationBase::GetDirectoryMetadata2(
|
||||
AssertIsOnIOThread();
|
||||
MOZ_ASSERT(aDirectory);
|
||||
|
||||
QM_TRY_VAR(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
QM_TRY_UNWRAP(auto binaryStream,
|
||||
GetBinaryInputStream(*aDirectory,
|
||||
nsLiteralString(METADATA_V2_FILE_NAME)));
|
||||
|
||||
QM_TRY_INSPECT(const uint64_t& timestamp,
|
||||
MOZ_TO_RESULT_INVOKE(binaryStream, Read64));
|
||||
@ -11072,7 +11074,8 @@ void OriginParser::HandleTrailingSeparator() {
|
||||
nsresult RepositoryOperationBase::ProcessRepository() {
|
||||
AssertIsOnIOThread();
|
||||
|
||||
QM_DEBUG_TRY_VAR(const bool exists, MOZ_TO_RESULT_INVOKE(mDirectory, Exists));
|
||||
QM_DEBUG_TRY_UNWRAP(const bool exists,
|
||||
MOZ_TO_RESULT_INVOKE(mDirectory, Exists));
|
||||
MOZ_ASSERT(exists);
|
||||
|
||||
QM_TRY(CollectEachFileEntry(
|
||||
@ -11103,8 +11106,8 @@ nsresult RepositoryOperationBase::ProcessRepository() {
|
||||
}
|
||||
|
||||
if (originProps.mType != OriginProps::eObsolete) {
|
||||
QM_TRY_VAR(
|
||||
const bool removed,
|
||||
QM_TRY_INSPECT(
|
||||
const bool& removed,
|
||||
MOZ_TO_RESULT_INVOKE(self, PrepareOriginDirectory, originProps));
|
||||
if (removed) {
|
||||
return mozilla::Ok{};
|
||||
@ -11152,8 +11155,8 @@ nsresult RepositoryOperationBase::MaybeUpgradeClients(
|
||||
QM_TRY_INSPECT(const auto& leafName,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsString, dir, GetLeafName));
|
||||
|
||||
QM_TRY_VAR(
|
||||
const bool removed,
|
||||
QM_TRY_INSPECT(
|
||||
const bool& removed,
|
||||
MOZ_TO_RESULT_INVOKE(self, PrepareClientDirectory, dir, leafName));
|
||||
if (removed) {
|
||||
return mozilla::Ok{};
|
||||
@ -11401,7 +11404,7 @@ nsresult CreateOrUpgradeDirectoryMetadataHelper::ProcessOriginDirectory(
|
||||
return rv;
|
||||
}
|
||||
|
||||
QM_TRY_VAR(auto stream, GetBinaryOutputStream(*file, kAppendFileFlag));
|
||||
QM_TRY_UNWRAP(auto stream, GetBinaryOutputStream(*file, kAppendFileFlag));
|
||||
|
||||
MOZ_ASSERT(stream);
|
||||
|
||||
@ -11480,9 +11483,9 @@ nsresult UpgradeStorageFrom1_0To2_0Helper::MaybeRemoveMorgueDirectory(
|
||||
// working. So recover these profiles permanently by removing these corrupt
|
||||
// directories as part of this upgrade.
|
||||
|
||||
QM_TRY_VAR(auto morgueDir,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aOriginProps.mDirectory, Clone));
|
||||
QM_TRY_UNWRAP(auto morgueDir,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aOriginProps.mDirectory, Clone));
|
||||
|
||||
QM_TRY(morgueDir->Append(u"morgue"_ns));
|
||||
|
||||
@ -11564,9 +11567,9 @@ UpgradeStorageFrom1_0To2_0Helper::MaybeStripObsoleteOriginAttributes(
|
||||
/* aPersisted */ false, aOriginProps.mSuffix,
|
||||
aOriginProps.mGroup, aOriginProps.mOrigin));
|
||||
|
||||
QM_TRY_VAR(auto newFile,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aOriginProps.mDirectory, GetParent));
|
||||
QM_TRY_UNWRAP(auto newFile,
|
||||
MOZ_TO_RESULT_INVOKE_TYPED(nsCOMPtr<nsIFile>,
|
||||
aOriginProps.mDirectory, GetParent));
|
||||
|
||||
QM_TRY(newFile->Append(newLeafName));
|
||||
|
||||
|
@ -540,7 +540,7 @@
|
||||
accessFunction, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* QM_TRY_VAR(target, expr[, customRetVal, cleanup]) is the C++ equivalent of
|
||||
* QM_TRY_UNWRAP(target, expr[, customRetVal, cleanup]) is the C++ equivalent of
|
||||
* Rust's `target = try!(expr);`. First, it evaluates expr, which must produce
|
||||
* a Result value. On success, the result's success value is unwrapped and
|
||||
* assigned to target. On error, it calls HandleError and an additional cleanup
|
||||
@ -548,7 +548,7 @@
|
||||
* result or a custom return value (if the third argument was passed). |target|
|
||||
* must be an lvalue.
|
||||
*/
|
||||
#define QM_TRY_VAR(...) QM_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define QM_TRY_UNWRAP(...) QM_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* QM_TRY_INSPECT is similar to QM_TRY_VAR, but it does not unwrap a success
|
||||
@ -559,7 +559,7 @@
|
||||
*
|
||||
* should be preferred over
|
||||
*
|
||||
* QM_TRY_VAR(const auto target, DoSomething())
|
||||
* QM_TRY_UNWRAP(const auto target, DoSomething())
|
||||
*
|
||||
* as it avoids unnecessary moves/copies.
|
||||
*/
|
||||
@ -570,9 +570,9 @@
|
||||
* in non-debug builds.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
# define QM_DEBUG_TRY_VAR(...) QM_TRY_VAR(__VA_ARGS__)
|
||||
# define QM_DEBUG_TRY_UNWRAP(...) QM_TRY_UNWRAP(__VA_ARGS__)
|
||||
#else
|
||||
# define QM_DEBUG_TRY_VAR(...)
|
||||
# define QM_DEBUG_TRY_UNWRAP(...)
|
||||
#endif
|
||||
|
||||
// QM_TRY_RETURN_PROPAGATE_ERR, QM_TRY_RETURN_CUSTOM_RET_VAL,
|
||||
|
@ -503,15 +503,6 @@ TEST(QuotaCommon_TryInspect, Failure_WithCleanup_UnwrapErr)
|
||||
EXPECT_EQ(rv, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryVar, Decl)
|
||||
{
|
||||
QM_TRY_VAR(int32_t x, (Result<int32_t, nsresult>{42}), QM_VOID);
|
||||
|
||||
static_assert(std::is_same_v<decltype(x), int32_t>);
|
||||
|
||||
EXPECT_EQ(x, 42);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryInspect, ConstDecl)
|
||||
{
|
||||
QM_TRY_INSPECT(const int32_t& x, (Result<int32_t, nsresult>{42}), QM_VOID);
|
||||
@ -540,19 +531,6 @@ TEST(QuotaCommon_TryInspect, SameLine)
|
||||
EXPECT_EQ(y, 42);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryVar, ParenDecl)
|
||||
{
|
||||
QM_TRY_VAR((const auto [x, y]),
|
||||
(Result<std::pair<int32_t, bool>, nsresult>{std::pair{42, true}}),
|
||||
QM_VOID);
|
||||
|
||||
static_assert(std::is_same_v<decltype(x), const int32_t>);
|
||||
static_assert(std::is_same_v<decltype(y), const bool>);
|
||||
|
||||
EXPECT_EQ(x, 42);
|
||||
EXPECT_EQ(y, true);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryInspect, NestingMadness_Success)
|
||||
{
|
||||
bool nestedTryInspectDidNotReturn = false;
|
||||
@ -717,76 +695,112 @@ TEST(QuotaCommon_TryInspect, NestingMadness_Multiple_Failure2)
|
||||
EXPECT_EQ(rv, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_DebugTryVar, Success)
|
||||
// We are not repeating all QM_TRY_INSPECT test cases for QM_TRY_UNWRAP, since
|
||||
// they are largely based on the same implementation. We just add some where
|
||||
// inspecting and unwrapping differ.
|
||||
|
||||
TEST(QuotaCommon_TryUnwrap, NonConstDecl)
|
||||
{
|
||||
bool debugTryVarBodyRan = false;
|
||||
bool debugTryVarDidNotReturn = false;
|
||||
QM_TRY_UNWRAP(int32_t x, (Result<int32_t, nsresult>{42}), QM_VOID);
|
||||
|
||||
static_assert(std::is_same_v<decltype(x), int32_t>);
|
||||
|
||||
EXPECT_EQ(x, 42);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryUnwrap, RvalueDecl)
|
||||
{
|
||||
QM_TRY_UNWRAP(int32_t && x, (Result<int32_t, nsresult>{42}), QM_VOID);
|
||||
|
||||
static_assert(std::is_same_v<decltype(x), int32_t&&>);
|
||||
|
||||
EXPECT_EQ(x, 42);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_TryUnwrap, ParenDecl)
|
||||
{
|
||||
QM_TRY_UNWRAP(
|
||||
(auto&& [x, y]),
|
||||
(Result<std::pair<int32_t, bool>, nsresult>{std::pair{42, true}}),
|
||||
QM_VOID);
|
||||
|
||||
static_assert(std::is_same_v<decltype(x), int32_t>);
|
||||
static_assert(std::is_same_v<decltype(y), bool>);
|
||||
|
||||
EXPECT_EQ(x, 42);
|
||||
EXPECT_EQ(y, true);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_DebugTryUnwrap, Success)
|
||||
{
|
||||
bool debugTryUnwrapBodyRan = false;
|
||||
bool debugTryUnwrapDidNotReturn = false;
|
||||
|
||||
nsresult rv = [
|
||||
#ifdef DEBUG
|
||||
&debugTryVarBodyRan, &debugTryVarDidNotReturn
|
||||
&debugTryUnwrapBodyRan, &debugTryUnwrapDidNotReturn
|
||||
#else
|
||||
&debugTryVarDidNotReturn
|
||||
&debugTryUnwrapDidNotReturn
|
||||
#endif
|
||||
]() -> nsresult {
|
||||
QM_DEBUG_TRY_VAR(const auto x,
|
||||
([&debugTryVarBodyRan]() -> Result<int32_t, nsresult> {
|
||||
debugTryVarBodyRan = true;
|
||||
QM_DEBUG_TRY_UNWRAP(
|
||||
const auto x, ([&debugTryUnwrapBodyRan]() -> Result<int32_t, nsresult> {
|
||||
debugTryUnwrapBodyRan = true;
|
||||
|
||||
return 42;
|
||||
}()));
|
||||
return 42;
|
||||
}()));
|
||||
#ifdef DEBUG
|
||||
EXPECT_EQ(x, 42);
|
||||
#endif
|
||||
|
||||
debugTryVarDidNotReturn = true;
|
||||
debugTryUnwrapDidNotReturn = true;
|
||||
|
||||
return NS_OK;
|
||||
}();
|
||||
|
||||
#ifdef DEBUG
|
||||
EXPECT_TRUE(debugTryVarBodyRan);
|
||||
EXPECT_TRUE(debugTryUnwrapBodyRan);
|
||||
#else
|
||||
EXPECT_FALSE(debugTryVarBodyRan);
|
||||
EXPECT_FALSE(debugTryUnwrapBodyRan);
|
||||
#endif
|
||||
EXPECT_TRUE(debugTryVarDidNotReturn);
|
||||
EXPECT_TRUE(debugTryUnwrapDidNotReturn);
|
||||
EXPECT_EQ(rv, NS_OK);
|
||||
}
|
||||
|
||||
TEST(QuotaCommon_DebugTryVar, Failure)
|
||||
TEST(QuotaCommon_DebugTryUnwrap, Failure)
|
||||
{
|
||||
bool debugTryVarBodyRan = false;
|
||||
bool debugTryVarDidNotReturn = false;
|
||||
bool debugTryUnwrapBodyRan = false;
|
||||
bool debugTryUnwrapDidNotReturn = false;
|
||||
|
||||
nsresult rv = [
|
||||
#ifdef DEBUG
|
||||
&debugTryVarBodyRan, &debugTryVarDidNotReturn
|
||||
&debugTryUnwrapBodyRan, &debugTryUnwrapDidNotReturn
|
||||
#else
|
||||
&debugTryVarDidNotReturn
|
||||
&debugTryUnwrapDidNotReturn
|
||||
#endif
|
||||
]() -> nsresult {
|
||||
QM_DEBUG_TRY_VAR(const auto x,
|
||||
([&debugTryVarBodyRan]() -> Result<int32_t, nsresult> {
|
||||
debugTryVarBodyRan = true;
|
||||
QM_DEBUG_TRY_UNWRAP(
|
||||
const auto x, ([&debugTryUnwrapBodyRan]() -> Result<int32_t, nsresult> {
|
||||
debugTryUnwrapBodyRan = true;
|
||||
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}()));
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
}()));
|
||||
#ifdef DEBUG
|
||||
Unused << x;
|
||||
#endif
|
||||
|
||||
debugTryVarDidNotReturn = true;
|
||||
debugTryUnwrapDidNotReturn = true;
|
||||
|
||||
return NS_OK;
|
||||
}();
|
||||
|
||||
#ifdef DEBUG
|
||||
EXPECT_TRUE(debugTryVarBodyRan);
|
||||
EXPECT_FALSE(debugTryVarDidNotReturn);
|
||||
EXPECT_TRUE(debugTryUnwrapBodyRan);
|
||||
EXPECT_FALSE(debugTryUnwrapDidNotReturn);
|
||||
EXPECT_EQ(rv, NS_ERROR_FAILURE);
|
||||
#else
|
||||
EXPECT_FALSE(debugTryVarBodyRan);
|
||||
EXPECT_TRUE(debugTryVarDidNotReturn);
|
||||
EXPECT_FALSE(debugTryUnwrapBodyRan);
|
||||
EXPECT_TRUE(debugTryUnwrapDidNotReturn);
|
||||
EXPECT_EQ(rv, NS_OK);
|
||||
#endif
|
||||
}
|
||||
|
@ -1653,8 +1653,8 @@ Result<UsageInfo, nsresult> QuotaClient::GetUsageForOrigin(
|
||||
QuotaManager* quotaManager = QuotaManager::Get();
|
||||
MOZ_ASSERT(quotaManager);
|
||||
|
||||
SDB_TRY_VAR(auto directory,
|
||||
quotaManager->GetDirectoryForOrigin(aPersistenceType, aOrigin));
|
||||
SDB_TRY_UNWRAP(auto directory, quotaManager->GetDirectoryForOrigin(
|
||||
aPersistenceType, aOrigin));
|
||||
|
||||
MOZ_ASSERT(directory);
|
||||
|
||||
|
@ -24,13 +24,13 @@
|
||||
#define SDB_TRY_VAR_GLUE(accessFunction, ...) \
|
||||
QM_TRY_VAR_META(mozilla::dom::simpledb, MOZ_UNIQUE_VAR(tryResult), \
|
||||
accessFunction, ##__VA_ARGS__)
|
||||
#define SDB_TRY_VAR(...) SDB_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define SDB_TRY_UNWRAP(...) SDB_TRY_VAR_GLUE(unwrap, __VA_ARGS__)
|
||||
#define SDB_TRY_INSPECT(...) SDB_TRY_VAR_GLUE(inspect, __VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
# define SDB_DEBUG_TRY_VAR(...) SDB_TRY_VAR(__VA_ARGS__)
|
||||
# define SDB_DEBUG_TRY_UNWRAP(...) SDB_TRY_UNWRAP(__VA_ARGS__)
|
||||
#else
|
||||
# define SDB_DEBUG_TRY_VAR(...)
|
||||
# define SDB_DEBUG_TRY_UNWRAP(...)
|
||||
#endif
|
||||
|
||||
// SimpleDB equivalents of QM_TRY_RETURN and QM_DEBUG_TRY_RETURN.
|
||||
|
Loading…
Reference in New Issue
Block a user