From 11b00c8709e8edefd15a0bca626b1179245d998e Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Wed, 23 Oct 2024 20:17:07 +0000 Subject: [PATCH] Bug 1926565 - QM: Add a way to detect a closed CachingDatabaseConnection; r=dom-storage-reviewers,jstutte Differential Revision: https://phabricator.services.mozilla.com/D226647 --- dom/quota/CachingDatabaseConnection.cpp | 2 ++ dom/quota/CachingDatabaseConnection.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/dom/quota/CachingDatabaseConnection.cpp b/dom/quota/CachingDatabaseConnection.cpp index dfdf0f71da76..19099a062e47 100644 --- a/dom/quota/CachingDatabaseConnection.cpp +++ b/dom/quota/CachingDatabaseConnection.cpp @@ -93,6 +93,8 @@ void CachingDatabaseConnection::Close() { MOZ_ALWAYS_SUCCEEDS((*mStorageConnection)->Close()); mStorageConnection.destroy(); + + mClosed = true; } #if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) diff --git a/dom/quota/CachingDatabaseConnection.h b/dom/quota/CachingDatabaseConnection.h index c9d7dbdd6bcc..f88eeae0f7a2 100644 --- a/dom/quota/CachingDatabaseConnection.h +++ b/dom/quota/CachingDatabaseConnection.h @@ -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 GetCachedStatement( const nsACString& aQuery); @@ -136,6 +139,7 @@ class CachingDatabaseConnection { mStorageConnection; nsInterfaceHashtable mCachedStatements; + Atomic mClosed; }; class CachingDatabaseConnection::CachedStatement final {