Bug 1371882 - Remove unneeded MediaCache::mContentLength - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 15 Jun 2017 17:32:26 +1200
changeset 595171 8cfd39d929c28cf06f3e01c75b27be01e21b57d2
parent 595170 e3276ec587259bedda46b99500a65c7b9d5abed2
child 633640 cd39205cc3fa36781c5a2eac8fbcb46230bc207e
push id64265
push usergsquelart@mozilla.com
push dateFri, 16 Jun 2017 03:37:56 +0000
reviewerscpearce
bugs1371882
milestone56.0a1
Bug 1371882 - Remove unneeded MediaCache::mContentLength - r?cpearce Now that MediaCache doesn't use the content length to decide which block cache to use, and can know it's the file-backed MediaCache (to reset the pointer, and for telemetry purposes), we don't need to store mContentLength anymore. MozReview-Commit-ID: KjxarKFe9WK
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -246,19 +246,18 @@ public:
     }
   private:
     MediaCache* mMediaCache;
     int64_t  mResourceID;
     uint32_t mNext;
   };
 
 protected:
-  explicit MediaCache(int64_t aContentLength, MediaBlockCacheBase* aCache)
-    : mContentLength(aContentLength)
-    , mNextResourceID(1)
+  explicit MediaCache(MediaBlockCacheBase* aCache)
+    : mNextResourceID(1)
     , mReentrantMonitor("MediaCache.mReentrantMonitor")
     , mBlockCache(aCache)
     , mUpdateQueued(false)
 #ifdef DEBUG
     , mInUpdate(false)
 #endif
   {
     NS_ASSERTION(NS_IsMainThread(), "Only construct MediaCache on main thread");
@@ -388,21 +387,16 @@ protected:
   void Truncate();
 
   // There is at most one file-backed media cache.
   // It is owned by all MediaCacheStreams that use it.
   // This is a raw pointer set by GetMediaCache(), and reset by ~MediaCache(),
   // both on the main thread; and is not accessed anywhere else.
   static MediaCache* gMediaCache;
 
-  // Expected content length if known initially from the HTTP Content-Length
-  // header (this is a memory-backed MediaCache), otherwise -1 (file-backed
-  // MediaCache).
-  const int64_t mContentLength;
-
   // This member is main-thread only. It's used to allocate unique
   // resource IDs to streams.
   int64_t                       mNextResourceID;
 
   // The monitor protects all the data members here. Also, off-main-thread
   // readers that need to block will Wait() on this monitor. When new
   // data becomes available in the cache, we NotifyAll() on this monitor.
   ReentrantMonitor         mReentrantMonitor;
@@ -690,17 +684,17 @@ MediaCache::GetMediaCache(int64_t aConte
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   if (aContentLength > 0 &&
       aContentLength <= int64_t(MediaPrefs::MediaMemoryCacheMaxSize()) * 1024) {
     // Small-enough resource, use a new memory-backed MediaCache.
     RefPtr<MediaBlockCacheBase> bc = new MemoryBlockCache(aContentLength);
     nsresult rv = bc->Init();
     if (NS_SUCCEEDED(rv)) {
-      RefPtr<MediaCache> mc = new MediaCache(aContentLength, bc);
+      RefPtr<MediaCache> mc = new MediaCache(bc);
       LOG("GetMediaCache(%" PRIi64 ") -> Memory MediaCache %p",
           aContentLength,
           mc.get());
       return mc;
     }
     // MemoryBlockCache initialization failed, clean up and try for a
     // file-backed MediaCache below.
   }
@@ -709,17 +703,17 @@ MediaCache::GetMediaCache(int64_t aConte
     LOG("GetMediaCache(%" PRIi64 ") -> Existing file-backed MediaCache",
         aContentLength);
     return gMediaCache;
   }
 
   RefPtr<MediaBlockCacheBase> bc = new FileBlockCache();
   nsresult rv = bc->Init();
   if (NS_SUCCEEDED(rv)) {
-    gMediaCache = new MediaCache(-1, bc);
+    gMediaCache = new MediaCache(bc);
     LOG("GetMediaCache(%" PRIi64 ") -> Created file-backed MediaCache",
         aContentLength);
   } else {
     LOG("GetMediaCache(%" PRIi64 ") -> Failed to create file-backed MediaCache",
         aContentLength);
   }
 
   return gMediaCache;