mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1208371 - Guard LoadManagerSingleton with a WeakPtr. r=pkerr
LoadManagerSingleton has a separate shutdown path (xpcom-shutdown) from its users (Audio/VideoConduit - garbage collected). These have appeared racy, so in some cases the singleton was destructed before the users had deregistered (e.g., when conduits destructed by SnowWhiteKiller). A WeakPtr can solve this. MozReview-Commit-ID: AVrpd3QqOGx --HG-- extra : rebase_source : c5d50f7619940b772c7d1f3dee3ac0b6568ccfd9
This commit is contained in:
parent
903e51a6f9
commit
79cdda9e6f
@ -7,6 +7,7 @@
|
||||
#define _LOADMANAGER_H_
|
||||
|
||||
#include "LoadMonitor.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Services.h"
|
||||
@ -23,12 +24,15 @@ namespace mozilla {
|
||||
class LoadManagerSingleton : public LoadNotificationCallback,
|
||||
public webrtc::CPULoadStateCallbackInvoker,
|
||||
public webrtc::CpuOveruseObserver,
|
||||
public SupportsWeakPtr<LoadManagerSingleton>,
|
||||
public nsIObserver
|
||||
|
||||
{
|
||||
public:
|
||||
static LoadManagerSingleton* Get();
|
||||
|
||||
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LoadManagerSingleton)
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
@ -86,23 +90,31 @@ public:
|
||||
|
||||
void AddObserver(webrtc::CPULoadStateObserver * aObserver) override
|
||||
{
|
||||
mManager->AddObserver(aObserver);
|
||||
if (mManager) {
|
||||
mManager->AddObserver(aObserver);
|
||||
}
|
||||
}
|
||||
void RemoveObserver(webrtc::CPULoadStateObserver * aObserver) override
|
||||
{
|
||||
mManager->RemoveObserver(aObserver);
|
||||
if (mManager) {
|
||||
mManager->RemoveObserver(aObserver);
|
||||
}
|
||||
}
|
||||
void OveruseDetected() override
|
||||
{
|
||||
mManager->OveruseDetected();
|
||||
if (mManager) {
|
||||
mManager->OveruseDetected();
|
||||
}
|
||||
}
|
||||
void NormalUsage() override
|
||||
{
|
||||
mManager->NormalUsage();
|
||||
if (mManager) {
|
||||
mManager->NormalUsage();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
LoadManagerSingleton* mManager;
|
||||
WeakPtr<LoadManagerSingleton> mManager;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
Loading…
Reference in New Issue
Block a user