Bug 1421875. P3 - remove MediaDecoder::DownloadProgressed() which is basically a one-line call to GetOwner()->DownloadProgressed(). r=bechen,gerald
authorJW Wang <jwwang@mozilla.com>
Thu, 30 Nov 2017 11:21:14 +0800
changeset 394502 7872c5484cd1b5d7a0e7bc79a7291f586cf9bfa9
parent 394501 ef7f09a38f92f6be601349a4269ef0af3987921f
child 394503 19831481168fe0cdf720bd61c76e8883bd8a6ae8
push id33006
push userrgurzau@mozilla.com
push dateFri, 01 Dec 2017 10:52:03 +0000
treeherdermozilla-central@ab629f447e6c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbechen, gerald
bugs1421875
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 1421875. P3 - remove MediaDecoder::DownloadProgressed() which is basically a one-line call to GetOwner()->DownloadProgressed(). r=bechen,gerald Also devirtualize ChannelMediaDecoder::DownloadProgressed() and move it to private. MozReview-Commit-ID: ITv3ISRbN5t
dom/media/ChannelMediaDecoder.cpp
dom/media/ChannelMediaDecoder.h
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/hls/HLSDecoder.cpp
dom/media/mediasource/MediaSourceDecoder.cpp
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -377,18 +377,19 @@ ChannelMediaDecoder::DurationChanged()
   // Duration has changed so we should recompute playback rate
   UpdatePlaybackRate();
 }
 
 void
 ChannelMediaDecoder::DownloadProgressed()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   AbstractThread::AutoEnter context(AbstractMainThread());
-  MediaDecoder::DownloadProgressed();
+  GetOwner()->DownloadProgressed();
   UpdatePlaybackRate();
   mResource->ThrottleReadahead(ShouldThrottleDownload());
 }
 
 void
 ChannelMediaDecoder::ComputePlaybackRate()
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/ChannelMediaDecoder.h
+++ b/dom/media/ChannelMediaDecoder.h
@@ -53,17 +53,16 @@ class ChannelMediaDecoder : public Media
     nsCOMPtr<nsITimer> mTimer;
     bool mTimerArmed = false;
     const RefPtr<AbstractThread> mAbstractMainThread;
   };
 
 protected:
   void OnPlaybackEvent(MediaEventType aEvent) override;
   void DurationChanged() override;
-  void DownloadProgressed() override;
   void MetadataLoaded(UniquePtr<MediaInfo> aInfo,
                       UniquePtr<MetadataTags> aTags,
                       MediaDecoderEventVisibility aEventVisibility) override;
 
   RefPtr<ResourceCallback> mResourceCallback;
   RefPtr<BaseMediaResource> mResource;
 
   explicit ChannelMediaDecoder(MediaDecoderInit& aInit);
@@ -93,16 +92,17 @@ public:
   void AddSizeOfResources(ResourceSizes* aSizes) override;
   already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
   bool IsTransportSeekable() override;
   void SetLoadInBackground(bool aLoadInBackground) override;
   void Suspend() override;
   void Resume() override;
 
 private:
+  void DownloadProgressed();
   void PinForSeek() override;
   void UnpinForSeek() override;
 
   // Create a new state machine to run this decoder.
   MediaDecoderStateMachine* CreateStateMachine();
 
   nsresult Load(BaseMediaResource* aOriginal);
 
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -949,25 +949,16 @@ MediaDecoder::PlaybackEnded()
   LOG("MediaDecoder::PlaybackEnded");
 
   ChangeState(PLAY_STATE_ENDED);
   InvalidateWithFlags(VideoFrameContainer::INVALIDATE_FORCE);
   GetOwner()->PlaybackEnded();
 }
 
 void
-MediaDecoder::DownloadProgressed()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
-  AbstractThread::AutoEnter context(AbstractMainThread());
-  GetOwner()->DownloadProgressed();
-}
-
-void
 MediaDecoder::NotifyPrincipalChanged()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   AbstractThread::AutoEnter context(AbstractMainThread());
   nsCOMPtr<nsIPrincipal> newPrincipal = GetCurrentPrincipal();
   mMediaPrincipalHandle = MakePrincipalHandle(newPrincipal);
   GetOwner()->NotifyDecoderPrincipalChanged();
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -509,20 +509,16 @@ private:
   // Explicitly prievate to force access via accessors.
   RefPtr<MediaDecoderStateMachine> mDecoderStateMachine;
 
 protected:
   void NotifyReaderDataArrived();
   void DiscardOngoingSeekIfExists();
   virtual void CallSeek(const SeekTarget& aTarget);
 
-  // Called to notify fetching media data is in progress.
-  // Called on the main thread only.
-  virtual void DownloadProgressed();
-
   // Called by MediaResource when the principal of the resource has
   // changed. Called on main thread only.
   void NotifyPrincipalChanged();
 
   MozPromiseRequestHolder<SeekPromise> mSeekRequest;
 
   const char* PlayStateStr();
 
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -240,13 +240,15 @@ HLSDecoder::Shutdown()
   }
   MediaDecoder::Shutdown();
 }
 
 void
 HLSDecoder::NotifyDataArrived()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
+  AbstractThread::AutoEnter context(AbstractMainThread());
   NotifyReaderDataArrived();
-  DownloadProgressed();
+  GetOwner()->DownloadProgressed();
 }
 
 } // namespace mozilla
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -352,18 +352,20 @@ MediaSourceDecoder::NotifyInitDataArrive
     mDemuxer->NotifyInitDataArrived();
   }
 }
 
 void
 MediaSourceDecoder::NotifyDataArrived()
 {
   MOZ_ASSERT(NS_IsMainThread());
+  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
+  AbstractThread::AutoEnter context(AbstractMainThread());
   NotifyReaderDataArrived();
-  DownloadProgressed();
+  GetOwner()->DownloadProgressed();
 }
 
 already_AddRefed<nsIPrincipal>
 MediaSourceDecoder::GetCurrentPrincipal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   return do_AddRef(mPrincipal);
 }