Skip to content

Commit

Permalink
Bug 1791767 - Exclude CachingDatabaseConnection with event target fro…
Browse files Browse the repository at this point in the history
…m general thread checks. r=dom-storage-reviewers,janv

CachingDatabaseConnection relies on a global macro to toggle thread
ownership checks. The checks do not work with thread pool event targets
and by this change we ensure that the global macro users are not
impacted by such event target changes.

Depends on D190598

Differential Revision: https://phabricator.services.mozilla.com/D190601
  • Loading branch information
jjjalkanen committed Oct 16, 2023
1 parent 485e9fb commit 9ca4cc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dom/quota/CachingDatabaseConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace mozilla::dom::quota {
CachingDatabaseConnection::CachingDatabaseConnection(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection)
:
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP
mOwningThread{nsAutoOwningThread{}},
#endif
mStorageConnection(std::move(aStorageConnection)) {
}

void CachingDatabaseConnection::LazyInit(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection) {
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP
mOwningThread.init();
#endif
mStorageConnection.init(std::move(aStorageConnection));
Expand Down
4 changes: 2 additions & 2 deletions dom/quota/CachingDatabaseConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CachingDatabaseConnection {
class LazyStatement;

void AssertIsOnConnectionThread() const {
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP
mOwningThread->AssertOwnership("CachingDatabaseConnection not thread-safe");
#endif
}
Expand Down Expand Up @@ -125,7 +125,7 @@ class CachingDatabaseConnection {
void Close();

private:
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
#ifdef CACHING_DB_CONNECTION_CHECK_THREAD_OWNERSHIP
LazyInitializedOnce<const nsAutoOwningThread> mOwningThread;
#endif

Expand Down
10 changes: 10 additions & 0 deletions dom/quota/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@
# 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_

0 comments on commit 9ca4cc5

Please sign in to comment.