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 f5c399d83f
commit 80961933e1
3 changed files with 4 additions and 14 deletions

View File

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

View File

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

View File

@ -33,14 +33,4 @@
# define QM_COLLECTING_OPERATION_TELEMETRY
#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_