Bug 1398659. P5 - let ChannelMediaResource::Open() set mListener without calling OpenChannel(). r=gerald
authorJW Wang <jwwang@mozilla.com>
Tue, 05 Sep 2017 17:51:22 +0800
changeset 662279 aae0f0941029a26fd24661bd629ab8f4182560a1
parent 662278 bd93f2e8986baa83c634612dc013a4d42781b09d
child 662280 020a6054e22840ec66c1f0e0a0bfa3a83040cc7c
push id79014
push userbmo:bpostelnicu@mozilla.com
push dateMon, 11 Sep 2017 09:58:20 +0000
reviewersgerald
bugs1398659
milestone57.0a1
Bug 1398659. P5 - let ChannelMediaResource::Open() set mListener without calling OpenChannel(). r=gerald This is more efficient because aStreamListener won't be null. MozReview-Commit-ID: 4b22l7cTK6y
dom/media/MediaResource.cpp
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -531,17 +531,20 @@ ChannelMediaResource::Open(nsIStreamList
   }
 
   nsresult rv = mCacheStream.Init(cl);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   MOZ_ASSERT(mOffset == 0, "Who set mOffset already?");
-  return OpenChannel(aStreamListener);
+  mListener = new Listener(this);
+  *aStreamListener = mListener;
+  NS_ADDREF(*aStreamListener);
+  return NS_OK;
 }
 
 nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener)
 {
   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");