Bug 1415090. P5 - remove MediaCacheStream::NotifyChannelRecreated(). r=bechen,gerald
authorJW Wang <jwwang@mozilla.com>
Thu, 16 Nov 2017 14:50:49 +0800
changeset 392648 fdb2a41005f2c8ae4d3528c893821f9eb06b3f0c
parent 392647 222597bfd33b3d40b37cae4cc86651768e2143e1
child 392649 7d1e7299eb81afe46c91a69fe8e433ec8eb2a2f7
push id97491
push userebalazs@mozilla.com
push dateMon, 20 Nov 2017 09:48:38 +0000
treeherdermozilla-inbound@54749fccb7b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbechen, gerald
bugs1415090
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 1415090. P5 - remove MediaCacheStream::NotifyChannelRecreated(). r=bechen,gerald NotifyDataEnded() runs off the main thread which might set mChannelEnded wrongly after NotifyChannelRecreated reset it on the main thread. We should reset the flags in NotifyDataStarted() which indicate a new load has begun. MozReview-Commit-ID: Gi6PFXwMJqc
dom/media/ChannelMediaResource.cpp
dom/media/MediaCache.cpp
dom/media/MediaCache.h
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -791,19 +791,16 @@ ChannelMediaResource::RecreateChannel()
 
   nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(mChannel));
   if (cos) {
     // Unconditionally disable throttling since we want the media to fluently
     // play even when we switch the tab to background.
     cos->AddClassFlags(nsIClassOfService::DontThrottle);
   }
 
-  // Tell the cache to reset the download status when the channel is reopened.
-  mCacheStream.NotifyChannelRecreated();
-
   return rv;
 }
 
 void
 ChannelMediaResource::CacheClientNotifyDataReceived()
 {
   SystemGroup::Dispatch(
     TaskCategory::Other,
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1977,16 +1977,20 @@ MediaCacheStream::NotifyDataStarted(uint
   mIsTransportSeekable = aSeekable;
   // Queue an Update since we may change our strategy for dealing
   // with this stream
   mMediaCache->QueueUpdate();
 
   // Reset mSeekTarget since the seek is completed so MediaCache::Update() will
   // make decisions based on mChannelOffset instead of mSeekTarget.
   mSeekTarget = -1;
+
+  // Reset these flags since a new load has begun.
+  mChannelEnded = false;
+  mDidNotifyDataEnded = false;
 }
 
 void
 MediaCacheStream::UpdatePrincipal(nsIPrincipal* aPrincipal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MediaCache::ResourceStreamIterator iter(mMediaCache, mResourceID);
   while (MediaCacheStream* stream = iter.Next()) {
@@ -2187,25 +2191,16 @@ MediaCacheStream::NotifyDataEndedInterna
       stream->mDidNotifyDataEnded = true;
       stream->mNotifyDataEndedStatus = aStatus;
       stream->mClient->CacheClientNotifyDataEnded(aStatus);
     }
   }
 }
 
 void
-MediaCacheStream::NotifyChannelRecreated()
-{
-  NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
-  ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
-  mChannelEnded = false;
-  mDidNotifyDataEnded = false;
-}
-
-void
 MediaCacheStream::NotifyDataEnded(uint32_t aLoadID,
                                   nsresult aStatus,
                                   bool aReopenOnError)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aLoadID > 0);
 
   RefPtr<ChannelMediaResource> client = mClient;
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -273,20 +273,16 @@ public:
   // preceding NotifyDataStarted().
   void NotifyLoadID(uint32_t aLoadID);
 
   // Notifies the cache that the channel has closed with the given status.
   void NotifyDataEnded(uint32_t aLoadID,
                        nsresult aStatus,
                        bool aReopenOnError = false);
 
-  // Notifies the stream that the channel is reopened. The stream should
-  // reset variables such as |mDidNotifyDataEnded|.
-  void NotifyChannelRecreated();
-
   // Notifies the stream that the suspend status of the client has changed.
   // Main thread only.
   void NotifyClientSuspended(bool aSuspended);
 
   // These methods can be called on any thread.
   // Cached blocks associated with this stream will not be evicted
   // while the stream is pinned.
   void Pin();