Bug 1428951 - add a getter for MediaCacheStream::GetDebugInfo() to take the cache monitor on the main thread. r=bechen,gerald
authorJW Wang <jwwang@mozilla.com>
Tue, 09 Jan 2018 10:29:10 +0800
changeset 452761 1599fb3b361022c56638a1570272068dc69eb268
parent 452760 ed6cf025df1352cf5f9e8f6be8d09debf5b69801
child 452762 78bb2af7c912124443ee144e967a301a68680211
child 452797 8f679a1bd3a99bd1d0e64fd941bd6776c9dc23e6
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbechen, gerald
bugs1428951
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 1428951 - add a getter for MediaCacheStream::GetDebugInfo() to take the cache monitor on the main thread. r=bechen,gerald MozReview-Commit-ID: 8qkZg0MJsGQ
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -467,16 +467,26 @@ protected:
   // A list of resource IDs to notify about the change in suspended status.
   nsTArray<int64_t> mSuspendedStatusToNotify;
   // The thread on which we will run data callbacks from the channels.
   // Note this thread is shared among all MediaCache instances.
   static StaticRefPtr<nsIThread> sThread;
   // True if we've tried to init sThread. Note we try once only so it is safe
   // to access sThread on all threads.
   static bool sThreadInit;
+
+private:
+  // Used by MediaCacheStream::GetDebugInfo() only for debugging.
+  // Don't add new callers to this function.
+  friend nsCString MediaCacheStream::GetDebugInfo();
+  mozilla::Monitor& GetMonitorOnTheMainThread()
+  {
+    MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
+    return mMonitor;
+  }
 };
 
 // Initialized to nullptr by non-local static initialization.
 /* static */ MediaCache* MediaCache::gMediaCache;
 
 /* static */ StaticRefPtr<nsIThread> MediaCache::sThread;
 /* static */ bool MediaCache::sThreadInit = false;
 
@@ -2979,17 +2989,17 @@ MediaCacheStream::GetDownloadRate(bool* 
   MOZ_ASSERT(!NS_IsMainThread());
   AutoLock lock(mMediaCache->Monitor());
   return mDownloadStatistics.GetRate(aIsReliable);
 }
 
 nsCString
 MediaCacheStream::GetDebugInfo()
 {
-  AutoLock lock(mMediaCache->Monitor());
+  AutoLock lock(mMediaCache->GetMonitorOnTheMainThread());
   return nsPrintfCString("mStreamLength=%" PRId64 " mChannelOffset=%" PRId64
                          " mCacheSuspended=%d mChannelEnded=%d mLoadID=%u",
                          mStreamLength,
                          mChannelOffset,
                          mCacheSuspended,
                          mChannelEnded,
                          mLoadID);
 }