Bug 1398659. P6 - remove the nsIStreamListener** parameter from OpenChannel(). r=gerald
authorJW Wang <jwwang@mozilla.com>
Thu, 07 Sep 2017 15:12:15 +0800
changeset 662280 020a6054e22840ec66c1f0e0a0bfa3a83040cc7c
parent 662279 aae0f0941029a26fd24661bd629ab8f4182560a1
child 662281 44e400e8dc12a39dc0acdfb7bad79325df6b6b52
push id79014
push userbmo:bpostelnicu@mozilla.com
push dateMon, 11 Sep 2017 09:58:20 +0000
reviewersgerald
bugs1398659
milestone57.0a1
Bug 1398659. P6 - remove the nsIStreamListener** parameter from OpenChannel(). r=gerald The only caller is CacheClientSeek() which always passes nullptr to it. MozReview-Commit-ID: 3CTkbF6ktp2
dom/media/MediaResource.cpp
dom/media/MediaResource.h
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -537,58 +537,50 @@ ChannelMediaResource::Open(nsIStreamList
 
   MOZ_ASSERT(mOffset == 0, "Who set mOffset already?");
   mListener = new Listener(this);
   *aStreamListener = mListener;
   NS_ADDREF(*aStreamListener);
   return NS_OK;
 }
 
-nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener)
+nsresult
+ChannelMediaResource::OpenChannel()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   NS_ENSURE_TRUE(mChannel, NS_ERROR_NULL_POINTER);
   NS_ASSERTION(!mListener, "Listener should have been removed by now");
 
-  if (aStreamListener) {
-    *aStreamListener = nullptr;
-  }
-
   // Set the content length, if it's available as an HTTP header.
   // This ensures that MediaResource wrapping objects for platform libraries
   // that expect to know the length of a resource can get it before
   // OnStartRequest() fires.
   nsCOMPtr<nsIHttpChannel> hc = do_QueryInterface(mChannel);
   if (hc && !IsPayloadCompressed(hc)) {
     int64_t cl = -1;
     if (NS_SUCCEEDED(hc->GetContentLength(&cl)) && cl != -1) {
       mCacheStream.NotifyDataLength(cl);
     }
   }
 
   mListener = new Listener(this);
-  if (aStreamListener) {
-    *aStreamListener = mListener;
-    NS_ADDREF(*aStreamListener);
-  } else {
-    nsresult rv = mChannel->SetNotificationCallbacks(mListener.get());
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = mChannel->SetNotificationCallbacks(mListener.get());
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = SetupChannelHeaders();
-    NS_ENSURE_SUCCESS(rv, rv);
+  rv = SetupChannelHeaders();
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = mChannel->AsyncOpen2(mListener);
-    NS_ENSURE_SUCCESS(rv, rv);
+  rv = mChannel->AsyncOpen2(mListener);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    // Tell the media element that we are fetching data from a channel.
-    MediaDecoderOwner* owner = mCallback->GetMediaOwner();
-    NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
-    dom::HTMLMediaElement* element = owner->GetMediaElement();
-    element->DownloadResumed(true);
-  }
+  // Tell the media element that we are fetching data from a channel.
+  MediaDecoderOwner* owner = mCallback->GetMediaOwner();
+  NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
+  dom::HTMLMediaElement* element = owner->GetMediaElement();
+  element->DownloadResumed(true);
 
   return NS_OK;
 }
 
 nsresult ChannelMediaResource::SetupChannelHeaders()
 {
   // Always use a byte range request even if we're reading from the start
   // of the resource.
@@ -906,17 +898,17 @@ ChannelMediaResource::CacheClientSeek(in
   // be recreated when we are resumed.
   if (mSuspendAgent.IsSuspended()) {
     return NS_OK;
   }
 
   nsresult rv = RecreateChannel();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return OpenChannel(nullptr);
+  return OpenChannel();
 }
 
 nsresult
 ChannelMediaResource::CacheClientSuspend()
 {
   Suspend(false);
   return NS_OK;
 }
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -535,17 +535,17 @@ protected:
   nsresult OnStopRequest(nsIRequest* aRequest, nsresult aStatus);
   nsresult OnDataAvailable(nsIRequest* aRequest,
                            nsIInputStream* aStream,
                            uint32_t aCount);
   nsresult OnChannelRedirect(nsIChannel* aOld, nsIChannel* aNew, uint32_t aFlags);
 
   // Opens the channel, using an HTTP byte range request to start at mOffset
   // if possible. Main thread only.
-  nsresult OpenChannel(nsIStreamListener** aStreamListener);
+  nsresult OpenChannel();
   nsresult RecreateChannel();
   // Add headers to HTTP request. Main thread only.
   nsresult SetupChannelHeaders();
   // Closes the channel. Main thread only.
   void CloseChannel();
 
   // Parses 'Content-Range' header and returns results via parameters.
   // Returns error if header is not available, values are not parse-able or