Loading dom/media/MediaCache.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include "nsIObserverService.h" #include "nsPrintfCString.h" #include "nsProxyRelease.h" #include "nsTHashSet.h" #include "nsThreadUtils.h" #include "prio.h" #include "VideoUtils.h" Loading Loading @@ -1068,15 +1069,14 @@ void MediaCache::SwapBlocks(AutoLock& aLock, int32_t aBlockIndex1, // Now update references to blocks in block lists. mFreeBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); nsTHashtable<nsPtrHashKey<MediaCacheStream> > visitedStreams; nsTHashSet<MediaCacheStream*> visitedStreams; for (int32_t i = 0; i < 2; ++i) { for (uint32_t j = 0; j < blocks[i]->mOwners.Length(); ++j) { MediaCacheStream* stream = blocks[i]->mOwners[j].mStream; // Make sure that we don't update the same stream twice --- that // would result in swapping the block references back again! if (visitedStreams.GetEntry(stream)) continue; visitedStreams.PutEntry(stream); if (!visitedStreams.EnsureInserted(stream)) continue; stream->mReadaheadBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); stream->mPlayedBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); stream->mMetadataBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); Loading dom/media/MediaFormatReader.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "mozilla/Unused.h" #include "nsContentUtils.h" #include "nsPrintfCString.h" #include "nsTHashSet.h" using namespace mozilla::media; Loading Loading @@ -75,7 +76,7 @@ class MediaFormatReader::ShutdownPromisePool { private: bool mShutdown = false; const RefPtr<ShutdownPromise::Private> mOnShutdownComplete; nsTHashtable<nsRefPtrHashKey<ShutdownPromise>> mPromises; nsTHashSet<RefPtr<ShutdownPromise>> mPromises; }; RefPtr<ShutdownPromise> MediaFormatReader::ShutdownPromisePool::Shutdown() { Loading @@ -91,10 +92,10 @@ void MediaFormatReader::ShutdownPromisePool::Track( RefPtr<ShutdownPromise> aPromise) { MOZ_DIAGNOSTIC_ASSERT(!mShutdown); MOZ_DIAGNOSTIC_ASSERT(!mPromises.Contains(aPromise)); mPromises.PutEntry(aPromise); mPromises.Insert(aPromise); aPromise->Then(AbstractThread::GetCurrent(), __func__, [aPromise, this]() { MOZ_DIAGNOSTIC_ASSERT(mPromises.Contains(aPromise)); mPromises.RemoveEntry(aPromise); mPromises.Remove(aPromise); if (mShutdown && mPromises.Count() == 0) { mOnShutdownComplete->Resolve(true, __func__); } Loading dom/media/MediaShutdownManager.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ nsresult MediaShutdownManager::Register(MediaDecoder* aDecoder) { // 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); mDecoders.Insert(aDecoder); MOZ_ASSERT(mDecoders.Contains(aDecoder)); MOZ_ASSERT(mDecoders.Count() > 0); return NS_OK; Loading @@ -113,10 +113,9 @@ nsresult MediaShutdownManager::Register(MediaDecoder* aDecoder) { void MediaShutdownManager::Unregister(MediaDecoder* aDecoder) { MOZ_ASSERT(NS_IsMainThread()); if (!mDecoders.Contains(aDecoder)) { if (!mDecoders.EnsureRemoved(aDecoder)) { return; } mDecoders.RemoveEntry(aDecoder); if (sInitPhase == XPCOMShutdownStarted && mDecoders.Count() == 0) { RemoveBlocker(); } Loading Loading @@ -150,8 +149,8 @@ MediaShutdownManager::BlockShutdown(nsIAsyncShutdownClient*) { } // Iterate over the decoders and shut them down. for (auto iter = mDecoders.Iter(); !iter.Done(); iter.Next()) { iter.Get()->GetKey()->NotifyXPCOMShutdown(); for (const auto& key : mDecoders) { key->NotifyXPCOMShutdown(); // Check MediaDecoder::Shutdown doesn't call Unregister() synchronously in // order not to corrupt our hashtable traversal. MOZ_ASSERT(mDecoders.Count() == oldCount); Loading dom/media/MediaShutdownManager.h +2 −3 Original line number Diff line number Diff line Loading @@ -13,8 +13,7 @@ # include "nsCOMPtr.h" # include "nsIAsyncShutdown.h" # include "nsIThread.h" # include "nsHashKeys.h" # include "nsTHashtable.h" # include "nsTHashSet.h" namespace mozilla { Loading Loading @@ -89,7 +88,7 @@ class MediaShutdownManager : public nsIAsyncShutdownBlocker { // References to the MediaDecoder. The decoders unregister themselves // in their Shutdown() method, so we'll drop the reference naturally when // we're shutting down (in the non xpcom-shutdown case). nsTHashtable<nsRefPtrHashKey<MediaDecoder>> mDecoders; nsTHashSet<RefPtr<MediaDecoder>> mDecoders; }; } // namespace mozilla Loading dom/media/gmp/GMPTimerParent.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ mozilla::ipc::IPCResult GMPTimerParent::RecvSetTimer( ctx->mId = aTimerId; ctx->mParent = this; mTimers.PutEntry(ctx.release()); mTimers.Insert(ctx.release()); return IPC_OK(); } Loading @@ -57,8 +57,7 @@ void GMPTimerParent::Shutdown() { MOZ_ASSERT(mGMPEventTarget->IsOnCurrentThread()); for (auto iter = mTimers.Iter(); !iter.Done(); iter.Next()) { Context* context = iter.Get()->GetKey(); for (Context* context : mTimers) { context->mTimer->Cancel(); delete context; } Loading Loading @@ -94,7 +93,7 @@ void GMPTimerParent::TimerExpired(Context* aContext) { } uint32_t id = aContext->mId; mTimers.RemoveEntry(aContext); mTimers.Remove(aContext); if (id) { Unused << SendTimerExpired(id); } Loading Loading
dom/media/MediaCache.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include "nsIObserverService.h" #include "nsPrintfCString.h" #include "nsProxyRelease.h" #include "nsTHashSet.h" #include "nsThreadUtils.h" #include "prio.h" #include "VideoUtils.h" Loading Loading @@ -1068,15 +1069,14 @@ void MediaCache::SwapBlocks(AutoLock& aLock, int32_t aBlockIndex1, // Now update references to blocks in block lists. mFreeBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); nsTHashtable<nsPtrHashKey<MediaCacheStream> > visitedStreams; nsTHashSet<MediaCacheStream*> visitedStreams; for (int32_t i = 0; i < 2; ++i) { for (uint32_t j = 0; j < blocks[i]->mOwners.Length(); ++j) { MediaCacheStream* stream = blocks[i]->mOwners[j].mStream; // Make sure that we don't update the same stream twice --- that // would result in swapping the block references back again! if (visitedStreams.GetEntry(stream)) continue; visitedStreams.PutEntry(stream); if (!visitedStreams.EnsureInserted(stream)) continue; stream->mReadaheadBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); stream->mPlayedBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); stream->mMetadataBlocks.NotifyBlockSwapped(aBlockIndex1, aBlockIndex2); Loading
dom/media/MediaFormatReader.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "mozilla/Unused.h" #include "nsContentUtils.h" #include "nsPrintfCString.h" #include "nsTHashSet.h" using namespace mozilla::media; Loading Loading @@ -75,7 +76,7 @@ class MediaFormatReader::ShutdownPromisePool { private: bool mShutdown = false; const RefPtr<ShutdownPromise::Private> mOnShutdownComplete; nsTHashtable<nsRefPtrHashKey<ShutdownPromise>> mPromises; nsTHashSet<RefPtr<ShutdownPromise>> mPromises; }; RefPtr<ShutdownPromise> MediaFormatReader::ShutdownPromisePool::Shutdown() { Loading @@ -91,10 +92,10 @@ void MediaFormatReader::ShutdownPromisePool::Track( RefPtr<ShutdownPromise> aPromise) { MOZ_DIAGNOSTIC_ASSERT(!mShutdown); MOZ_DIAGNOSTIC_ASSERT(!mPromises.Contains(aPromise)); mPromises.PutEntry(aPromise); mPromises.Insert(aPromise); aPromise->Then(AbstractThread::GetCurrent(), __func__, [aPromise, this]() { MOZ_DIAGNOSTIC_ASSERT(mPromises.Contains(aPromise)); mPromises.RemoveEntry(aPromise); mPromises.Remove(aPromise); if (mShutdown && mPromises.Count() == 0) { mOnShutdownComplete->Resolve(true, __func__); } Loading
dom/media/MediaShutdownManager.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ nsresult MediaShutdownManager::Register(MediaDecoder* aDecoder) { // 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); mDecoders.Insert(aDecoder); MOZ_ASSERT(mDecoders.Contains(aDecoder)); MOZ_ASSERT(mDecoders.Count() > 0); return NS_OK; Loading @@ -113,10 +113,9 @@ nsresult MediaShutdownManager::Register(MediaDecoder* aDecoder) { void MediaShutdownManager::Unregister(MediaDecoder* aDecoder) { MOZ_ASSERT(NS_IsMainThread()); if (!mDecoders.Contains(aDecoder)) { if (!mDecoders.EnsureRemoved(aDecoder)) { return; } mDecoders.RemoveEntry(aDecoder); if (sInitPhase == XPCOMShutdownStarted && mDecoders.Count() == 0) { RemoveBlocker(); } Loading Loading @@ -150,8 +149,8 @@ MediaShutdownManager::BlockShutdown(nsIAsyncShutdownClient*) { } // Iterate over the decoders and shut them down. for (auto iter = mDecoders.Iter(); !iter.Done(); iter.Next()) { iter.Get()->GetKey()->NotifyXPCOMShutdown(); for (const auto& key : mDecoders) { key->NotifyXPCOMShutdown(); // Check MediaDecoder::Shutdown doesn't call Unregister() synchronously in // order not to corrupt our hashtable traversal. MOZ_ASSERT(mDecoders.Count() == oldCount); Loading
dom/media/MediaShutdownManager.h +2 −3 Original line number Diff line number Diff line Loading @@ -13,8 +13,7 @@ # include "nsCOMPtr.h" # include "nsIAsyncShutdown.h" # include "nsIThread.h" # include "nsHashKeys.h" # include "nsTHashtable.h" # include "nsTHashSet.h" namespace mozilla { Loading Loading @@ -89,7 +88,7 @@ class MediaShutdownManager : public nsIAsyncShutdownBlocker { // References to the MediaDecoder. The decoders unregister themselves // in their Shutdown() method, so we'll drop the reference naturally when // we're shutting down (in the non xpcom-shutdown case). nsTHashtable<nsRefPtrHashKey<MediaDecoder>> mDecoders; nsTHashSet<RefPtr<MediaDecoder>> mDecoders; }; } // namespace mozilla Loading
dom/media/gmp/GMPTimerParent.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ mozilla::ipc::IPCResult GMPTimerParent::RecvSetTimer( ctx->mId = aTimerId; ctx->mParent = this; mTimers.PutEntry(ctx.release()); mTimers.Insert(ctx.release()); return IPC_OK(); } Loading @@ -57,8 +57,7 @@ void GMPTimerParent::Shutdown() { MOZ_ASSERT(mGMPEventTarget->IsOnCurrentThread()); for (auto iter = mTimers.Iter(); !iter.Done(); iter.Next()) { Context* context = iter.Get()->GetKey(); for (Context* context : mTimers) { context->mTimer->Cancel(); delete context; } Loading Loading @@ -94,7 +93,7 @@ void GMPTimerParent::TimerExpired(Context* aContext) { } uint32_t id = aContext->mId; mTimers.RemoveEntry(aContext); mTimers.Remove(aContext); if (id) { Unused << SendTimerExpired(id); } Loading