Bug 1428242. P2 - MediaCache::ReadCacheFile() doesn't need to drop the cache monitor. r=bechen,gerald
authorJW Wang <jwwang@mozilla.com>
Fri, 05 Jan 2018 10:48:14 +0800
changeset 397922 90ffd059bdfa679780d7d4dd99a259e0f457546b
parent 397921 a5f886553c4beaea9816d24058a797a033b3e804
child 397923 c1bacce3317103a68433841841feb36813854c0b
push id57572
push userjwwang@mozilla.com
push dateFri, 05 Jan 2018 06:37:59 +0000
treeherderautoland@c1bacce33171 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbechen, gerald
bugs1428242, 1354389
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1428242. P2 - MediaCache::ReadCacheFile() doesn't need to drop the cache monitor. r=bechen,gerald Since we now never take the lock on the main thread, we can safely do file IO while holding the lock without blocking the main thread. This reverts the change of Bug 1354389 P1. MozReview-Commit-ID: EhEwTjINQIT
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -812,27 +812,20 @@ MediaCache::GetMediaCache(int64_t aConte
 
 nsresult
 MediaCache::ReadCacheFile(AutoLock&,
                           int64_t aOffset,
                           void* aData,
                           int32_t aLength,
                           int32_t* aBytes)
 {
-  RefPtr<MediaBlockCacheBase> blockCache = mBlockCache;
-  if (!blockCache) {
+  if (!mBlockCache) {
     return NS_ERROR_FAILURE;
   }
-  {
-    // Since the monitor might be acquired on the main thread, we need to drop
-    // the monitor while doing IO in order not to block the main thread.
-    AutoUnlock unlock(mMonitor);
-    return blockCache->Read(
-      aOffset, reinterpret_cast<uint8_t*>(aData), aLength, aBytes);
-  }
+  return mBlockCache->Read(aOffset, reinterpret_cast<uint8_t*>(aData), aLength, aBytes);
 }
 
 // Allowed range is whatever can be accessed with an int32_t block index.
 static bool
 IsOffsetAllowed(int64_t aOffset)
 {
   return aOffset < (int64_t(INT32_MAX) + 1) * MediaCache::BLOCK_SIZE &&
          aOffset >= 0;