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 {
|
||||
|
||||
// Guards sService and its members.
|
||||
StaticMutex sRefMessageBodyServiceMutex;
|
||||
|
||||
// Raw pointer because the service is kept alive by other objects.
|
||||
@ -35,16 +36,18 @@ already_AddRefed<RefMessageBodyService> RefMessageBodyService::GetOrCreate() {
|
||||
RefMessageBodyService* RefMessageBodyService::GetOrCreateInternal(
|
||||
const StaticMutexAutoLock& aProofOfLock) {
|
||||
if (!sService) {
|
||||
sService = new RefMessageBodyService();
|
||||
sService = new RefMessageBodyService(aProofOfLock);
|
||||
}
|
||||
return sService;
|
||||
}
|
||||
|
||||
RefMessageBodyService::RefMessageBodyService() {
|
||||
RefMessageBodyService::RefMessageBodyService(
|
||||
const StaticMutexAutoLock& aProofOfLock) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(sService == nullptr);
|
||||
}
|
||||
|
||||
RefMessageBodyService::~RefMessageBodyService() {
|
||||
StaticMutexAutoLock lock(sRefMessageBodyServiceMutex);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sService == this);
|
||||
sService = nullptr;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class RefMessageBodyService final {
|
||||
void SetMaxCount(const nsID& aID, uint32_t aMaxCount);
|
||||
|
||||
private:
|
||||
RefMessageBodyService();
|
||||
explicit RefMessageBodyService(const StaticMutexAutoLock& aProofOfLock);
|
||||
~RefMessageBodyService();
|
||||
|
||||
static RefMessageBodyService* GetOrCreateInternal(
|
||||
|
Loading…
x
Reference in New Issue
Block a user