Bug 1398659. P2 - remove the if statement since new() is infallible. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 05 Sep 2017 17:31:09 +0800
changeset 662139 d08f9fb77a3f840788f95359556d27d80c077118
parent 662138 2f6491b183f21996267ef150e6de9dfc0b5df861
child 662140 a5793e2d96b9d4fa13179f7ad773f4181aaf8a0c
push id78964
push userjwwang@mozilla.com
push dateMon, 11 Sep 2017 04:05:04 +0000
bugs1398659
milestone57.0a1
Bug 1398659. P2 - remove the if statement since new() is infallible. MozReview-Commit-ID: 9GobL4M2mjc
dom/media/MediaResource.cpp
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -645,27 +645,27 @@ bool ChannelMediaResource::CanClone()
 already_AddRefed<BaseMediaResource>
 ChannelMediaResource::CloneData(MediaResourceCallback* aCallback)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   NS_ASSERTION(mCacheStream.IsAvailableForSharing(), "Stream can't be cloned");
 
   RefPtr<ChannelMediaResource> resource =
     new ChannelMediaResource(aCallback, nullptr, mURI, mChannelStatistics);
-  if (resource) {
-    // Initially the clone is treated as suspended by the cache, because
-    // we don't have a channel. If the cache needs to read data from the clone
-    // it will call CacheClientResume (or CacheClientSeek with aResume true)
-    // which will recreate the channel. This way, if all of the media data
-    // is already in the cache we don't create an unnecessary HTTP channel
-    // and perform a useless HTTP transaction.
-    resource->mSuspendAgent.Suspend();
-    resource->mCacheStream.InitAsClone(&mCacheStream);
-    resource->mChannelStatistics.Stop();
-  }
+
+  // Initially the clone is treated as suspended by the cache, because
+  // we don't have a channel. If the cache needs to read data from the clone
+  // it will call CacheClientResume (or CacheClientSeek with aResume true)
+  // which will recreate the channel. This way, if all of the media data
+  // is already in the cache we don't create an unnecessary HTTP channel
+  // and perform a useless HTTP transaction.
+  resource->mSuspendAgent.Suspend();
+  resource->mCacheStream.InitAsClone(&mCacheStream);
+  resource->mChannelStatistics.Stop();
+
   return resource.forget();
 }
 
 void ChannelMediaResource::CloseChannel()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   mChannelStatistics.Stop();