Bug 1343787. Part 1 - allow MediaShutdownManager::Register() to fail.
MozReview-Commit-ID: 2pnPnq4NlXN
--- a/dom/media/MediaShutdownManager.cpp
+++ b/dom/media/MediaShutdownManager.cpp
@@ -86,34 +86,39 @@ MediaShutdownManager::RemoveBlocker()
MOZ_ASSERT(mDecoders.Count() == 0);
GetShutdownBarrier()->RemoveBlocker(this);
// Clear our singleton reference. This will probably delete
// this instance, so don't deref |this| clearing sInstance.
sInstance = nullptr;
DECODER_LOG(LogLevel::Debug, ("MediaShutdownManager::BlockShutdown() end."));
}
-void
+nsresult
MediaShutdownManager::Register(MediaDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_RELEASE_ASSERT(!mIsDoingXPCOMShutDown);
+ if (mIsDoingXPCOMShutDown) {
+ return NS_ERROR_ABORT;
+ }
// Don't call Register() after you've Unregistered() all the decoders,
// that's not going to work.
MOZ_ASSERT(!mDecoders.Contains(aDecoder));
mDecoders.PutEntry(aDecoder);
MOZ_ASSERT(mDecoders.Contains(aDecoder));
MOZ_ASSERT(mDecoders.Count() > 0);
+ return NS_OK;
}
void
MediaShutdownManager::Unregister(MediaDecoder* aDecoder)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(mDecoders.Contains(aDecoder));
+ if (!mDecoders.Contains(aDecoder)) {
+ return;
+ }
mDecoders.RemoveEntry(aDecoder);
if (mIsDoingXPCOMShutDown && mDecoders.Count() == 0) {
RemoveBlocker();
}
}
NS_IMETHODIMP
MediaShutdownManager::GetName(nsAString& aName)
--- a/dom/media/MediaShutdownManager.h
+++ b/dom/media/MediaShutdownManager.h
@@ -57,17 +57,17 @@ public:
static void InitStatics();
// The MediaShutdownManager is a singleton, access its instance with
// this accessor.
static MediaShutdownManager& Instance();
// Notifies the MediaShutdownManager that it needs to track the shutdown
// of this MediaDecoder.
- void Register(MediaDecoder* aDecoder);
+ nsresult Register(MediaDecoder* aDecoder);
// Notifies the MediaShutdownManager that a MediaDecoder that it was
// tracking has shutdown, and it no longer needs to be shutdown in the
// xpcom-shutdown listener.
void Unregister(MediaDecoder* aDecoder);
private: