Bug 1422657. P2 - remove unused mDecoderPosition and related code. r=bechen,gerald draft
authorJW Wang <jwwang@mozilla.com>
Fri, 01 Dec 2017 14:02:44 +0800
changeset 708102 2b9abaa1a22b78cadbbdbf99d1c778fe82f84eac
parent 708101 1f40adce4b93dbcf55cb3de9f5c16fdd6d0b6bee
child 708103 be9ecb4cc04b21665d8d25bdd44c25a06f26aa6d
push id92285
push userjwwang@mozilla.com
push dateWed, 06 Dec 2017 07:14:46 +0000
reviewersbechen, gerald
bugs1422657
milestone59.0a1
Bug 1422657. P2 - remove unused mDecoderPosition and related code. r=bechen,gerald MozReview-Commit-ID: 8RobmJKC40i
dom/media/BaseMediaResource.cpp
dom/media/BaseMediaResource.h
dom/media/ChannelMediaDecoder.cpp
dom/media/ChannelMediaDecoder.h
dom/media/ChannelMediaResource.cpp
dom/media/FileMediaResource.cpp
dom/media/MediaDecoder.h
dom/media/MediaResourceCallback.h
--- a/dom/media/BaseMediaResource.cpp
+++ b/dom/media/BaseMediaResource.cpp
@@ -154,18 +154,9 @@ BaseMediaResource::ModifyLoadFlags(nsLoa
   MOZ_ASSERT(NS_SUCCEEDED(rv), "SetLoadFlags() failed!");
 
   if (inLoadGroup) {
     rv = loadGroup->AddRequest(mChannel, nullptr);
     MOZ_ASSERT(NS_SUCCEEDED(rv), "AddRequest() failed!");
   }
 }
 
-void
-BaseMediaResource::DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset)
-{
-  if (aNumBytes <= 0) {
-    return;
-  }
-  mCallback->NotifyBytesConsumed(aNumBytes, aOffset);
-}
-
 } // namespace mozilla
--- a/dom/media/BaseMediaResource.h
+++ b/dom/media/BaseMediaResource.h
@@ -124,20 +124,16 @@ protected:
   }
   virtual ~BaseMediaResource() {}
 
   // Set the request's load flags to aFlags.  If the request is part of a
   // load group, the request is removed from the group, the flags are set, and
   // then the request is added back to the load group.
   void ModifyLoadFlags(nsLoadFlags aFlags);
 
-  // Dispatches an event to call MediaDecoder::NotifyBytesConsumed(aNumBytes, aOffset)
-  // on the main thread. This is called automatically after every read.
-  void DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset);
-
   RefPtr<MediaResourceCallback> mCallback;
 
   // Channel used to download the media data. Must be accessed
   // from the main thread only.
   nsCOMPtr<nsIChannel> mChannel;
 
   // URI in case the stream needs to be re-opened. Access from
   // main thread only.
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -126,40 +126,21 @@ ChannelMediaDecoder::ResourceCallback::N
   MOZ_ASSERT(NS_IsMainThread());
   MediaDecoderOwner* owner = GetMediaOwner();
   if (owner) {
     AbstractThread::AutoEnter context(owner->AbstractMainThread());
     owner->NotifySuspendedByCache(aSuspendedByCache);
   }
 }
 
-void
-ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
-                                                           int64_t aOffset)
-{
-  RefPtr<ResourceCallback> self = this;
-  nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
-    "ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed",
-    [=]() {
-    if (self->mDecoder) {
-      self->mDecoder->NotifyBytesConsumed(aBytes, aOffset);
-    }
-  });
-  mAbstractMainThread->Dispatch(r.forget());
-}
-
 ChannelMediaDecoder::ChannelMediaDecoder(MediaDecoderInit& aInit)
   : MediaDecoder(aInit)
   , mResourceCallback(new ResourceCallback(aInit.mOwner->AbstractMainThread()))
-  , mWatchManager(this, aInit.mOwner->AbstractMainThread())
 {
   mResourceCallback->Connect(this);
-
-  // mIgnoreProgressData
-  mWatchManager.Watch(mLogicallySeeking, &ChannelMediaDecoder::SeekingChanged);
 }
 
 /* static */
 already_AddRefed<ChannelMediaDecoder>
 ChannelMediaDecoder::Create(MediaDecoderInit& aInit,
                             DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -216,17 +197,16 @@ MediaDecoderStateMachine* ChannelMediaDe
   init.mMediaDecoderOwnerID = mOwner;
   mReader = DecoderTraits::CreateReader(ContainerType(), init);
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 void
 ChannelMediaDecoder::Shutdown()
 {
-  mWatchManager.Shutdown();
   mResourceCallback->Disconnect();
   MediaDecoder::Shutdown();
 
   // Force any outstanding seek and byterange requests to complete
   // to prevent shutdown from deadlocking.
   if (mResource) {
     mResource->Close();
   }
@@ -303,40 +283,16 @@ ChannelMediaDecoder::NotifyDownloadEnded
   } else if (aStatus == NS_BINDING_ABORTED) {
     // Download has been cancelled by user.
     owner->LoadAborted();
   } else {
     NetworkError(MediaResult(aStatus, "Download aborted"));
   }
 }
 
-void
-ChannelMediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
-  AbstractThread::AutoEnter context(AbstractMainThread());
-
-  if (mIgnoreProgressData) {
-    return;
-  }
-
-  MOZ_ASSERT(GetStateMachine());
-  mDecoderPosition = aOffset + aBytes;
-}
-
-void
-ChannelMediaDecoder::SeekingChanged()
-{
-  // Stop updating the bytes downloaded for progress notifications when
-  // seeking to prevent wild changes to the progress notification.
-  MOZ_ASSERT(NS_IsMainThread());
-  mIgnoreProgressData = mLogicallySeeking;
-}
-
 bool
 ChannelMediaDecoder::CanPlayThroughImpl()
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE(GetStateMachine(), false);
   return GetStatistics(ComputePlaybackRate()).CanPlayThrough();
 }
 
--- a/dom/media/ChannelMediaDecoder.h
+++ b/dom/media/ChannelMediaDecoder.h
@@ -39,17 +39,16 @@ class ChannelMediaDecoder : public Media
     /* MediaResourceCallback functions */
     AbstractThread* AbstractMainThread() const override;
     MediaDecoderOwner* GetMediaOwner() const override;
     void NotifyNetworkError(const MediaResult& aError) override;
     void NotifyDataArrived() override;
     void NotifyDataEnded(nsresult aStatus) override;
     void NotifyPrincipalChanged() override;
     void NotifySuspendedStatusChanged(bool aSuspendedByCache) override;
-    void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) override;
 
     static void TimerCallback(nsITimer* aTimer, void* aClosure);
 
     // The decoder to send notifications. Main-thread only.
     ChannelMediaDecoder* mDecoder = nullptr;
     nsCOMPtr<nsITimer> mTimer;
     bool mTimerArmed = false;
     const RefPtr<AbstractThread> mAbstractMainThread;
@@ -110,18 +109,16 @@ private:
   // Called on the main thread only. aStatus is the result from OnStopRequest.
   void NotifyDownloadEnded(nsresult aStatus);
 
   // Called by the MediaResource to keep track of the number of bytes read
   // from the resource. Called on the main by an event runner dispatched
   // by the MediaResource read functions.
   void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset);
 
-  void SeekingChanged();
-
   bool CanPlayThroughImpl() override final;
 
   bool IsLiveStream() override final;
 
   struct PlaybackRateInfo
   {
     uint32_t mRate; // Estimate of the current playback rate (bytes/second).
     bool mReliable; // True if mRate is a reliable estimate.
@@ -136,24 +133,16 @@ private:
   // Return statistics. This is used for progress events and other things.
   // This can be called from any thread. It's only a snapshot of the
   // current state, since other threads might be changing the state
   // at any time.
   MediaStatistics GetStatistics(const PlaybackRateInfo& aInfo);
 
   bool ShouldThrottleDownload(const MediaStatistics& aStats);
 
-  WatchManager<ChannelMediaDecoder> mWatchManager;
-
-  // True when seeking or otherwise moving the play position around in
-  // such a manner that progress event data is inaccurate. This is set
-  // during seek and duration operations to prevent the progress indicator
-  // from jumping around. Read/Write on the main thread only.
-  bool mIgnoreProgressData = false;
-
   // Data needed to estimate playback data rate. The timeline used for
   // this estimate is "decode time" (where the "current time" is the
   // time of the last decoded video frame).
   MediaChannelStatistics mPlaybackStatistics;
 
   // True when our media stream has been pinned. We pin the stream
   // while seeking.
   bool mPinnedForSeek = false;
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -616,22 +616,17 @@ nsresult ChannelMediaResource::ReadFromC
 }
 
 nsresult ChannelMediaResource::ReadAt(int64_t aOffset,
                                       char* aBuffer,
                                       uint32_t aCount,
                                       uint32_t* aBytes)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
-
-  nsresult rv = mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
-  if (NS_SUCCEEDED(rv)) {
-    DispatchBytesConsumed(*aBytes, aOffset);
-  }
-  return rv;
+  return mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
 }
 
 void
 ChannelMediaResource::ThrottleReadahead(bool bThrottle)
 {
   mCacheStream.ThrottleReadahead(bThrottle);
 }
 
--- a/dom/media/FileMediaResource.cpp
+++ b/dom/media/FileMediaResource.cpp
@@ -166,19 +166,16 @@ FileMediaResource::ReadAt(int64_t aOffse
 
   nsresult rv;
   {
     MutexAutoLock lock(mLock);
     rv = UnsafeSeek(nsISeekableStream::NS_SEEK_SET, aOffset);
     if (NS_FAILED(rv)) return rv;
     rv = UnsafeRead(aBuffer, aCount, aBytes);
   }
-  if (NS_SUCCEEDED(rv)) {
-    DispatchBytesConsumed(*aBytes, aOffset);
-  }
   return rv;
 }
 
 already_AddRefed<MediaByteBuffer>
 FileMediaResource::UnsafeMediaReadAt(int64_t aOffset, uint32_t aCount)
 {
   RefPtr<MediaByteBuffer> bytes = new MediaByteBuffer();
   bool ok = bytes->SetLength(aCount, fallible);
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -643,22 +643,16 @@ protected:
   // used to listen the related events.
   class BackgroundVideoDecodingPermissionObserver;
   RefPtr<BackgroundVideoDecodingPermissionObserver> mVideoDecodingOberver;
 
   // True if we want to resume video decoding even the media element is in the
   // background.
   bool mIsBackgroundVideoDecodingAllowed;
 
-  // Current decoding position in the stream. This is where the decoder
-  // is up to consuming the stream. This is not adjusted during decoder
-  // seek operations, but it's updated at the end when we start playing
-  // back again.
-  int64_t mDecoderPosition = 0;
-
 public:
   AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
   AbstractCanonical<bool>* CanonicalPreservesPitch()
   {
     return &mPreservesPitch;
   }
   AbstractCanonical<bool>* CanonicalLooping()
   {
--- a/dom/media/MediaResourceCallback.h
+++ b/dom/media/MediaResourceCallback.h
@@ -48,18 +48,15 @@ public:
   virtual void NotifyDataEnded(nsresult aStatus) {}
 
   // Notify that the principal of MediaResource has changed.
   virtual void NotifyPrincipalChanged() {}
 
   // Notify that the "cache suspended" status of MediaResource changes.
   virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
 
-  // Notify the number of bytes read from the resource.
-  virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) {}
-
 protected:
   virtual ~MediaResourceCallback() {}
 };
 
 } // namespace mozilla
 
 #endif //MediaResourceCallback_h_