Bug 1626973 - Add assertions for result of MaybeUpdateSize. r=janv,dom-workers-and-storage-reviewers

Depends on D69580

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2020-04-03 16:16:50 +00:00
parent 1ca11f861a
commit 2e68c75bb1
3 changed files with 13 additions and 5 deletions

View File

@ -21,7 +21,9 @@ NS_IMETHODIMP FileQuotaStream<FileStreamBase>::SetEOF() {
nsresult rv = FileStreamBase::Tell(&offset);
NS_ENSURE_SUCCESS(rv, rv);
mQuotaObject->MaybeUpdateSize(offset, /* aTruncate */ true);
DebugOnly<bool> res =
mQuotaObject->MaybeUpdateSize(offset, /* aTruncate */ true);
MOZ_ASSERT(res);
}
return NS_OK;
@ -51,7 +53,9 @@ nsresult FileQuotaStream<FileStreamBase>::DoOpen() {
NS_ENSURE_SUCCESS(rv, rv);
if (mQuotaObject && (FileStreamBase::mOpenParams.ioFlags & PR_TRUNCATE)) {
mQuotaObject->MaybeUpdateSize(0, /* aTruncate */ true);
DebugOnly<bool> res =
mQuotaObject->MaybeUpdateSize(0, /* aTruncate */ true);
MOZ_ASSERT(res);
}
return NS_OK;

View File

@ -32,7 +32,7 @@ class QuotaObject {
const nsAString& Path() const { return mPath; }
bool MaybeUpdateSize(int64_t aSize, bool aTruncate);
[[nodiscard]] bool MaybeUpdateSize(int64_t aSize, bool aTruncate);
bool IncreaseSize(int64_t aDelta);

View File

@ -276,7 +276,9 @@ int xWrite(sqlite3_file* pFile, const void* zBuf, int iAmt,
"update its current size...");
sqlite_int64 currentSize;
if (xFileSize(pFile, &currentSize) == SQLITE_OK) {
p->quotaObject->MaybeUpdateSize(currentSize, /* aTruncate */ true);
DebugOnly<bool> res =
p->quotaObject->MaybeUpdateSize(currentSize, /* aTruncate */ true);
MOZ_ASSERT(res);
}
}
return rc;
@ -315,7 +317,9 @@ int xTruncate(sqlite3_file* pFile, sqlite_int64 size) {
"xTruncate failed on a quota-controlled file, attempting to "
"update its current size...");
if (xFileSize(pFile, &size) == SQLITE_OK) {
p->quotaObject->MaybeUpdateSize(size, /* aTruncate */ true);
DebugOnly<bool> res =
p->quotaObject->MaybeUpdateSize(size, /* aTruncate */ true);
MOZ_ASSERT(res);
}
}
}