diff --git a/dom/media/MediaCache.cpp b/dom/media/MediaCache.cpp index c101ca670a91..dc41c20213e6 100644 --- a/dom/media/MediaCache.cpp +++ b/dom/media/MediaCache.cpp @@ -1884,19 +1884,16 @@ MediaCacheStream::NotifyDataReceived(int64_t aSize, const char* aData) // This might happen off the main thread. MOZ_DIAGNOSTIC_ASSERT(!mClosed); - // Update principals before putting the data in the cache. This is important, - // we want to make sure all principals are updated before any consumer - // can see the new data. - // We do this without holding the cache monitor, in case the client wants - // to do something that takes a lock. + ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor()); { + // Need to acquire the monitor because this code might run + // off the main thread. MediaCache::ResourceStreamIterator iter(mMediaCache, mResourceID); while (MediaCacheStream* stream = iter.Next()) { stream->mClient->CacheClientUpdatePrincipal(); } } - ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor()); int64_t size = aSize; const char* data = aData; diff --git a/dom/media/MediaResource.cpp b/dom/media/MediaResource.cpp index f22ea09ad2c9..8c9fee9d041a 100644 --- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -889,12 +889,6 @@ ChannelMediaResource::UpdatePrincipal() void ChannelMediaResource::CacheClientUpdatePrincipal() { - // This might happen off the main thread. - if (NS_IsMainThread()) { - UpdatePrincipal(); - return; - } - SystemGroup::Dispatch( TaskCategory::Other, NewRunnableMethod("ChannelMediaResource::UpdatePrincipal",