mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 21:18:35 +00:00
Bug 1625801 - grab the lock when creating and destroying RefMessageBodyService. r=sg
Differential Revision: https://phabricator.services.mozilla.com/D102944
This commit is contained in:
parent
a4315ae315
commit
892361c25c
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
|
// Guards sService and its members.
|
||||||
StaticMutex sRefMessageBodyServiceMutex;
|
StaticMutex sRefMessageBodyServiceMutex;
|
||||||
|
|
||||||
// Raw pointer because the service is kept alive by other objects.
|
// Raw pointer because the service is kept alive by other objects.
|
||||||
@ -35,16 +36,18 @@ already_AddRefed<RefMessageBodyService> RefMessageBodyService::GetOrCreate() {
|
|||||||
RefMessageBodyService* RefMessageBodyService::GetOrCreateInternal(
|
RefMessageBodyService* RefMessageBodyService::GetOrCreateInternal(
|
||||||
const StaticMutexAutoLock& aProofOfLock) {
|
const StaticMutexAutoLock& aProofOfLock) {
|
||||||
if (!sService) {
|
if (!sService) {
|
||||||
sService = new RefMessageBodyService();
|
sService = new RefMessageBodyService(aProofOfLock);
|
||||||
}
|
}
|
||||||
return sService;
|
return sService;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefMessageBodyService::RefMessageBodyService() {
|
RefMessageBodyService::RefMessageBodyService(
|
||||||
|
const StaticMutexAutoLock& aProofOfLock) {
|
||||||
MOZ_DIAGNOSTIC_ASSERT(sService == nullptr);
|
MOZ_DIAGNOSTIC_ASSERT(sService == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefMessageBodyService::~RefMessageBodyService() {
|
RefMessageBodyService::~RefMessageBodyService() {
|
||||||
|
StaticMutexAutoLock lock(sRefMessageBodyServiceMutex);
|
||||||
MOZ_DIAGNOSTIC_ASSERT(sService == this);
|
MOZ_DIAGNOSTIC_ASSERT(sService == this);
|
||||||
sService = nullptr;
|
sService = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ class RefMessageBodyService final {
|
|||||||
void SetMaxCount(const nsID& aID, uint32_t aMaxCount);
|
void SetMaxCount(const nsID& aID, uint32_t aMaxCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefMessageBodyService();
|
explicit RefMessageBodyService(const StaticMutexAutoLock& aProofOfLock);
|
||||||
~RefMessageBodyService();
|
~RefMessageBodyService();
|
||||||
|
|
||||||
static RefMessageBodyService* GetOrCreateInternal(
|
static RefMessageBodyService* GetOrCreateInternal(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user