Bug 1374184. P1 - add NotifyDataArrivedInternal() and let ResourceCallback call it. draft
authorJW Wang <jwwang@mozilla.com>
Mon, 19 Jun 2017 14:15:00 +0800
changeset 597059 9c64d0a93f5f22b804d97c9dabaa7e9df80386c2
parent 597058 fa79e90ce056bce5fdd715a535a9067059f955ec
child 597060 25947f7d9be8d2f2817b14e80054bf0dcb5d85e9
push id64816
push userjwwang@mozilla.com
push dateTue, 20 Jun 2017 03:04:06 +0000
bugs1374184
milestone56.0a1
Bug 1374184. P1 - add NotifyDataArrivedInternal() and let ResourceCallback call it. MozReview-Commit-ID: GTmNrRtxJ0U
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -187,17 +187,17 @@ MediaDecoder::ResourceCallback::NotifyNe
 }
 
 /* static */ void
 MediaDecoder::ResourceCallback::TimerCallback(nsITimer* aTimer, void* aClosure)
 {
   MOZ_ASSERT(NS_IsMainThread());
   ResourceCallback* thiz = static_cast<ResourceCallback*>(aClosure);
   MOZ_ASSERT(thiz->mDecoder);
-  thiz->mDecoder->NotifyDataArrived();
+  thiz->mDecoder->NotifyDataArrivedInternal();
   thiz->mTimerArmed = false;
 }
 
 void
 MediaDecoder::ResourceCallback::NotifyDataArrived()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!mDecoder) {
@@ -1535,23 +1535,29 @@ void MediaDecoder::AddSizeOfResources(Re
   MOZ_ASSERT(NS_IsMainThread());
   if (GetResource()) {
     aSizes->mByteSize +=
       GetResource()->SizeOfIncludingThis(aSizes->mMallocSizeOf);
   }
 }
 
 void
-MediaDecoder::NotifyDataArrived()
+MediaDecoder::NotifyDataArrivedInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   mDataArrivedEvent.Notify();
 }
 
+void
+MediaDecoder::NotifyDataArrived()
+{
+  NotifyDataArrivedInternal();
+}
+
 // Provide access to the state machine object
 MediaDecoderStateMachine*
 MediaDecoder::GetStateMachine() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   return mDecoderStateMachine;
 }
 
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -584,16 +584,18 @@ protected:
 
   // Amount of buffered data ahead of current time required to consider that
   // the next frame is available.
   // An arbitrary value of 250ms is used.
   static constexpr auto DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED =
     media::TimeUnit::FromMicroseconds(250000);
 
 private:
+  void NotifyDataArrivedInternal();
+
   nsCString GetDebugInfo();
 
   // Called when the metadata from the media file has been loaded by the
   // state machine. Call on the main thread only.
   void MetadataLoaded(UniquePtr<MediaInfo> aInfo,
                       UniquePtr<MetadataTags> aTags,
                       MediaDecoderEventVisibility aEventVisibility);