Bug 837874: Check ObserverService before adding observers in MediaManager r=derf

This commit is contained in:
Randell Jesup 2013-02-07 22:14:21 -05:00
parent 81acab97c2
commit e800014959
2 changed files with 10 additions and 5 deletions

View File

@ -1487,7 +1487,9 @@ Navigator::OnNavigation()
#ifdef MOZ_MEDIA_NAVIGATOR
// Inform MediaManager in case there are live streams or pending callbacks.
MediaManager *manager = MediaManager::Get();
manager->OnNavigation(win->WindowID());
if (manager) {
manager->OnNavigation(win->WindowID());
}
#endif
if (mCameraManager) {
mCameraManager->OnNavigation(win->WindowID());

View File

@ -360,10 +360,13 @@ public:
NS_ASSERTION(NS_IsMainThread(), "Only create MediaManager on main thread");
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
obs->AddObserver(sSingleton, "xpcom-shutdown", false);
obs->AddObserver(sSingleton, "getUserMedia:response:allow", false);
obs->AddObserver(sSingleton, "getUserMedia:response:deny", false);
obs->AddObserver(sSingleton, "getUserMedia:revoke", false);
if (obs) {
obs->AddObserver(sSingleton, "xpcom-shutdown", false);
obs->AddObserver(sSingleton, "getUserMedia:response:allow", false);
obs->AddObserver(sSingleton, "getUserMedia:response:deny", false);
obs->AddObserver(sSingleton, "getUserMedia:revoke", false);
}
// else MediaManager won't work properly and will leak (see bug 837874)
}
return sSingleton;
}