Skip to content

Commit

Permalink
Bug 1626973 - Add assertions for result of MaybeUpdateSize. r=janv,do…
Browse files Browse the repository at this point in the history
…m-workers-and-storage-reviewers

Depends on D69580

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
sigiesec committed Apr 3, 2020
1 parent 1ca11f8 commit 2e68c75
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions dom/quota/FileStreams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dom/quota/QuotaObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 6 additions & 2 deletions storage/TelemetryVFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 2e68c75

Please sign in to comment.