Bug 1858989 - Change CachingDatabaseConnection to use serial event targets; r=dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D203293
This commit is contained in:
Jan Varga 2024-03-14 07:04:30 +00:00
parent 80961933e1
commit 46bc8aab00
2 changed files with 6 additions and 4 deletions

View File

@ -15,7 +15,7 @@ CachingDatabaseConnection::CachingDatabaseConnection(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection)
:
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread{nsAutoOwningThread{}},
mOwningEventTarget{nsAutoOwningEventTarget{}},
#endif
mStorageConnection(std::move(aStorageConnection)) {
}
@ -23,7 +23,7 @@ CachingDatabaseConnection::CachingDatabaseConnection(
void CachingDatabaseConnection::LazyInit(
MovingNotNull<nsCOMPtr<mozIStorageConnection>> aStorageConnection) {
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread.init();
mOwningEventTarget.init();
#endif
mStorageConnection.init(std::move(aStorageConnection));
}

View File

@ -14,6 +14,7 @@
#include "nscore.h"
#include "nsHashKeys.h"
#include "nsInterfaceHashtable.h"
#include "nsISupportsImpl.h"
#include "nsString.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
@ -68,7 +69,8 @@ class CachingDatabaseConnection {
void AssertIsOnConnectionThread() const {
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
mOwningThread->AssertOwnership("CachingDatabaseConnection not thread-safe");
mOwningEventTarget->AssertOwnership(
"CachingDatabaseConnection not thread-safe");
#endif
}
@ -126,7 +128,7 @@ class CachingDatabaseConnection {
private:
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
LazyInitializedOnce<const nsAutoOwningThread> mOwningThread;
LazyInitializedOnce<const nsAutoOwningEventTarget> mOwningEventTarget;
#endif
LazyInitializedOnceEarlyDestructible<