Bug 1858989 - Bring back owning thread assertions; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D203292
This commit is contained in:
Jan Varga
2024-03-14 07:04:30 +00:00
parent 8f1a76b4da
commit 37b56985d0
3 changed files with 4 additions and 14 deletions

View File

@@ -14,7 +14,7 @@ namespace mozilla::dom::quota {
CachingDatabaseConnection::CachingDatabaseConnection( CachingDatabaseConnection::CachingDatabaseConnection(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection) MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection)
: :
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP #ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread{nsAutoOwningThread{}}, mOwningThread{nsAutoOwningThread{}},
#endif #endif
mStorageConnection(std::move(aStorageConnection)) { mStorageConnection(std::move(aStorageConnection)) {
@@ -22,7 +22,7 @@ CachingDatabaseConnection::CachingDatabaseConnection(
void CachingDatabaseConnection::LazyInit( void CachingDatabaseConnection::LazyInit(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection) { MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection) {
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP #ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread.init(); mOwningThread.init();
#endif #endif
mStorageConnection.init(std::move(aStorageConnection)); mStorageConnection.init(std::move(aStorageConnection));

View File

@@ -67,7 +67,7 @@ class CachingDatabaseConnection {
class LazyStatement; class LazyStatement;
void AssertIsOnConnectionThread() const { void AssertIsOnConnectionThread() const {
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP #ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread->AssertOwnership("CachingDatabaseConnection not thread-safe"); mOwningThread->AssertOwnership("CachingDatabaseConnection not thread-safe");
#endif #endif
} }
@@ -125,7 +125,7 @@ class CachingDatabaseConnection {
void Close(); void Close();
private: private:
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP #ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
LazyInitializedOnce<const nsAutoOwningThread> mOwningThread; LazyInitializedOnce<const nsAutoOwningThread> mOwningThread;
#endif #endif

View File

@@ -33,14 +33,4 @@
# define QM_COLLECTING_OPERATION_TELEMETRY # define QM_COLLECTING_OPERATION_TELEMETRY
#endif #endif
/**
* The thread ownership checks in CachingDatabaseConnection assumes that the
* object lives on a single thread, not any serial event target.
* Defining CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP restores the checks.
* See bug 1858989.
*/
#if 0
# define CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP 1
#endif
#endif // DOM_QUOTA_CONFIG_H_ #endif // DOM_QUOTA_CONFIG_H_