Bug 1926565 - QM: Add a way to detect a closed CachingDatabaseConnection; r=dom-storage-reviewers,jstutte

Differential Revision: https://phabricator.services.mozilla.com/D226647
This commit is contained in:
Jan Varga 2024-10-23 20:17:07 +00:00
parent 40c2d54381
commit 11b00c8709
2 changed files with 6 additions and 0 deletions

View File

@ -93,6 +93,8 @@ void CachingDatabaseConnection::Close() {
MOZ_ALWAYS_SUCCEEDS((*mStorageConnection)->Close());
mStorageConnection.destroy();
mClosed = true;
}
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING)

View File

@ -17,6 +17,7 @@
#include "nsISupportsImpl.h"
#include "nsString.h"
#include "mozilla/Assertions.h"
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "mozilla/InitializedOnce.h"
#include "mozilla/NotNull.h"
@ -85,6 +86,8 @@ class CachingDatabaseConnection {
return **mStorageConnection;
}
bool Closed() const { return mClosed; }
Result<CachedStatement, nsresult> GetCachedStatement(
const nsACString& aQuery);
@ -136,6 +139,7 @@ class CachingDatabaseConnection {
mStorageConnection;
nsInterfaceHashtable<nsCStringHashKey, mozIStorageStatement>
mCachedStatements;
Atomic<bool> mClosed;
};
class CachingDatabaseConnection::CachedStatement final {