Bug 1343787. Part 1 - allow MediaShutdownManager::Register() to fail. r=gerald

MozReview-Commit-ID: 2pnPnq4NlXN

--HG--
extra : rebase_source : c24c38ff5bad0902cc454e606a62e4d2bf60a602
extra : source : 2fe2c0b335ba6d1c17220c0bcabe645d771f77ac
This commit is contained in:
JW Wang 2017-03-02 16:08:28 +08:00
Родитель 3c60a97e1f
Коммит d6b69e2a1d
2 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -91,24 +91,29 @@ MediaShutdownManager::RemoveBlocker()
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();

Просмотреть файл

@ -62,7 +62,7 @@ public:
// 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