Bug 1398659. P10 - remove ChannelMediaResource::mIgnoreClose. r=gerald
authorJW Wang <jwwang@mozilla.com>
Fri, 08 Sep 2017 11:20:39 +0800
changeset 662284 665409f64b7083a98033e61b7191d4b68ccaf1e4
parent 662283 efd3ef5ae6f93952fbdc0483a5ffe598b321e477
child 662285 fadb12f8f604e32db23b5e49beb1b55160a66c1a
push id79014
push userbmo:bpostelnicu@mozilla.com
push dateMon, 11 Sep 2017 09:58:20 +0000
reviewersgerald
bugs1398659
milestone57.0a1
Bug 1398659. P10 - remove ChannelMediaResource::mIgnoreClose. r=gerald mIgnoreClose is always set in conjunction with a call to CloseChannel(). Since mListener->Revoke() will prevent future OnStopRequest() calls from coming, it is unnecessary to set mIgnoreClose and therefore we can remove this member. MozReview-Commit-ID: HEXIhIUG8WN
dom/media/MediaResource.cpp
dom/media/MediaResource.h
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -77,31 +77,29 @@ NS_IMPL_RELEASE_WITH_DESTROY(MediaResour
 
 ChannelMediaResource::ChannelMediaResource(MediaResourceCallback* aCallback,
                                            nsIChannel* aChannel,
                                            nsIURI* aURI,
                                            bool aIsPrivateBrowsing)
   : BaseMediaResource(aCallback, aChannel, aURI)
   , mOffset(0)
   , mReopenOnError(false)
-  , mIgnoreClose(false)
   , mCacheStream(this, aIsPrivateBrowsing)
   , mSuspendAgent(mChannel)
 {
 }
 
 ChannelMediaResource::ChannelMediaResource(
   MediaResourceCallback* aCallback,
   nsIChannel* aChannel,
   nsIURI* aURI,
   const MediaChannelStatistics& aStatistics)
   : BaseMediaResource(aCallback, aChannel, aURI)
   , mOffset(0)
   , mReopenOnError(false)
-  , mIgnoreClose(false)
   , mCacheStream(this, /* aIsPrivateBrowsing = */ false)
   , mChannelStatistics(aStatistics)
   , mSuspendAgent(mChannel)
 {
 }
 
 ChannelMediaResource::~ChannelMediaResource()
 {
@@ -316,17 +314,16 @@ ChannelMediaResource::OnStartRequest(nsI
     // If we get an HTTP_OK_CODE response to our byte range request,
     // and the server isn't sending Accept-Ranges:bytes then we don't
     // support seeking. We also can't seek in compressed streams.
     seekable = !isCompressed && acceptsRanges;
   }
   mCacheStream.SetTransportSeekable(seekable);
   mChannelStatistics.Start();
   mReopenOnError = false;
-  mIgnoreClose = false;
 
   mSuspendAgent.UpdateSuspendedStatusIfNeeded();
 
   // Fires an initial progress event.
   owner->DownloadProgressed();
 
   return NS_OK;
 }
@@ -411,29 +408,27 @@ ChannelMediaResource::OnStopRequest(nsIR
     nsresult rv = CacheClientSeek(mOffset, false);
     if (NS_SUCCEEDED(rv)) {
       return rv;
     }
     // If the reopen/reseek fails, just fall through and treat this
     // error as fatal.
   }
 
-  if (!mIgnoreClose) {
-    mCacheStream.NotifyDataEnded(aStatus);
+  mCacheStream.NotifyDataEnded(aStatus);
 
-    // Move this request back into the foreground.  This is necessary for
-    // requests owned by video documents to ensure the load group fires
-    // OnStopRequest when restoring from session history.
-    nsLoadFlags loadFlags;
-    DebugOnly<nsresult> rv = mChannel->GetLoadFlags(&loadFlags);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadFlags() failed!");
+  // Move this request back into the foreground.  This is necessary for
+  // requests owned by video documents to ensure the load group fires
+  // OnStopRequest when restoring from session history.
+  nsLoadFlags loadFlags;
+  DebugOnly<nsresult> rv = mChannel->GetLoadFlags(&loadFlags);
+  NS_ASSERTION(NS_SUCCEEDED(rv), "GetLoadFlags() failed!");
 
-    if (loadFlags & nsIRequest::LOAD_BACKGROUND) {
-      ModifyLoadFlags(loadFlags & ~nsIRequest::LOAD_BACKGROUND);
-    }
+  if (loadFlags & nsIRequest::LOAD_BACKGROUND) {
+    ModifyLoadFlags(loadFlags & ~nsIRequest::LOAD_BACKGROUND);
   }
 
   return NS_OK;
 }
 
 nsresult
 ChannelMediaResource::OnChannelRedirect(nsIChannel* aOld, nsIChannel* aNew,
                                         uint32_t aFlags)
@@ -712,18 +707,16 @@ void ChannelMediaResource::Suspend(bool 
   }
   dom::HTMLMediaElement* element = owner->GetMediaElement();
   if (!element) {
     // Shutting down; do nothing.
     return;
   }
 
   if (mChannel && aCloseImmediately && mCacheStream.IsTransportSeekable()) {
-    // Kill off our channel right now, but don't tell anyone about it.
-    mIgnoreClose = true;
     CloseChannel();
     element->DownloadSuspended();
   }
 
   if (mSuspendAgent.Suspend()) {
     if (mChannel) {
       mChannelStatistics.Stop();
       element->DownloadSuspended();
@@ -867,20 +860,16 @@ ChannelMediaResource::CacheClientSeek(in
 
   LOG("CacheClientSeek requested for aOffset [%" PRId64 "] for decoder [%p]",
       aOffset, mCallback.get());
 
   CloseChannel();
 
   mOffset = aOffset;
 
-  // Don't report close of the channel because the channel is not closed for
-  // download ended, but for internal changes in the read position.
-  mIgnoreClose = true;
-
   if (aResume) {
     mSuspendAgent.Resume();
   }
 
   // Don't create a new channel if we are still suspended. The channel will
   // be recreated when we are resumed.
   if (mSuspendAgent.IsSuspended()) {
     return NS_OK;
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -568,19 +568,16 @@ protected:
                               uint32_t* aWriteCount);
 
   // Main thread access only
   int64_t            mOffset;
   RefPtr<Listener> mListener;
   // When this flag is set, if we get a network error we should silently
   // reopen the stream.
   bool               mReopenOnError;
-  // When this flag is set, we should not report the next close of the
-  // channel.
-  bool               mIgnoreClose;
 
   // Any thread access
   MediaCacheStream mCacheStream;
 
   MediaChannelStatistics mChannelStatistics;
   ChannelSuspendAgent mSuspendAgent;
 };