Bug 1266304. Part 2 - remove unnecessary template parameters. r=kaku.
authorJW Wang <jwwang@mozilla.com>
Fri, 22 Apr 2016 14:16:56 +0800
changeset 332335 b4d0ef7a0f1e752b51f7fb1a7c7f2b1549f7c3ec
parent 332334 1a8c3d77911de65b63869658a368d4242fb23818
child 332336 61fa023639b3e0296df9396687f77375fac2c0d2
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1266304
milestone48.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 1266304. Part 2 - remove unnecessary template parameters. r=kaku. MozReview-Commit-ID: E2TnNbMvJaR
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaFormatReader.h
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -14,16 +14,17 @@ extern LazyLogModule gMediaDecoderLog;
 #undef LOG
 #define LOG(...) \
   MOZ_LOG(gMediaDecoderLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
 
 // StartTimeRendezvous is a helper class that quarantines the first sample
 // until it gets a sample from both channels, such that we can be guaranteed
 // to know the start time by the time On{Audio,Video}Decoded is called on MDSM.
 class StartTimeRendezvous {
+  typedef MediaDecoderReader::MediaDataPromise MediaDataPromise;
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StartTimeRendezvous);
 
 public:
   StartTimeRendezvous(AbstractThread* aOwnerThread,
                       bool aHasAudio,
                       bool aHasVideo,
                       bool aForceZeroStartTime)
     : mOwnerThread(aOwnerThread)
@@ -51,33 +52,27 @@ public:
   RefPtr<HaveStartTimePromise> AwaitStartTime()
   {
     if (HaveStartTime()) {
       return HaveStartTimePromise::CreateAndResolve(true, __func__);
     }
     return mHaveStartTimePromise.Ensure(__func__);
   }
 
-  template<typename PromiseType>
-  struct PromiseSampleType {
-    typedef typename PromiseType::ResolveValueType::element_type Type;
-  };
-
-  template<typename PromiseType, MediaData::Type SampleType>
-  RefPtr<PromiseType>
-  ProcessFirstSample(typename PromiseSampleType<PromiseType>::Type* aData)
+  template<MediaData::Type SampleType>
+  RefPtr<MediaDataPromise>
+  ProcessFirstSample(MediaData* aData)
   {
-    typedef typename PromiseSampleType<PromiseType>::Type DataType;
-    typedef typename PromiseType::Private PromisePrivate;
+    typedef typename MediaDataPromise::Private PromisePrivate;
     MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
 
     MaybeSetChannelStartTime<SampleType>(aData->mTime);
 
     RefPtr<PromisePrivate> p = new PromisePrivate(__func__);
-    RefPtr<DataType> data = aData;
+    RefPtr<MediaData> data = aData;
     RefPtr<StartTimeRendezvous> self = this;
     AwaitStartTime()->Then(
       mOwnerThread, __func__,
       [p, data, self] () {
         MOZ_ASSERT(self->mOwnerThread->IsCurrentThreadIn());
         p->Resolve(data, __func__);
       },
       [p] () {
@@ -189,17 +184,17 @@ MediaDecoderReaderWrapper::RequestAudioD
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                        &MediaDecoderReader::RequestAudioData);
 
   if (!mStartTimeRendezvous->HaveStartTime()) {
     p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
-                &StartTimeRendezvous::ProcessFirstSample<MediaDataPromise, MediaData::AUDIO_DATA>,
+                &StartTimeRendezvous::ProcessFirstSample<MediaData::AUDIO_DATA>,
                 &StartTimeRendezvous::FirstSampleRejected<MediaData::AUDIO_DATA>)
          ->CompletionPromise();
   }
 
   return p->Then(mOwnerThread, __func__, this,
                  &MediaDecoderReaderWrapper::OnSampleDecoded,
                  &MediaDecoderReaderWrapper::OnNotDecoded)
           ->CompletionPromise();
@@ -218,17 +213,17 @@ MediaDecoderReaderWrapper::RequestVideoD
   }
 
   auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                        &MediaDecoderReader::RequestVideoData,
                        aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());
 
   if (!mStartTimeRendezvous->HaveStartTime()) {
     p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
-                &StartTimeRendezvous::ProcessFirstSample<MediaDataPromise, MediaData::VIDEO_DATA>,
+                &StartTimeRendezvous::ProcessFirstSample<MediaData::VIDEO_DATA>,
                 &StartTimeRendezvous::FirstSampleRejected<MediaData::VIDEO_DATA>)
          ->CompletionPromise();
   }
 
   return p->Then(mOwnerThread, __func__, this,
                  &MediaDecoderReaderWrapper::OnSampleDecoded,
                  &MediaDecoderReaderWrapper::OnNotDecoded)
           ->CompletionPromise();
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -361,43 +361,42 @@ private:
     // Sample format monitoring.
     uint32_t mLastStreamSourceID;
     Maybe<uint32_t> mNextStreamSourceID;
     media::TimeIntervals mTimeRanges;
     Maybe<media::TimeUnit> mLastTimeRangesEnd;
     RefPtr<SharedTrackInfo> mInfo;
   };
 
-  template<typename PromiseType>
   struct DecoderDataWithPromise : public DecoderData {
     DecoderDataWithPromise(MediaFormatReader* aOwner,
                            MediaData::Type aType,
                            uint32_t aDecodeAhead) :
       DecoderData(aOwner, aType, aDecodeAhead)
     {}
 
-    MozPromiseHolder<PromiseType> mPromise;
+    MozPromiseHolder<MediaDataPromise> mPromise;
 
     bool HasPromise() override
     {
       MOZ_ASSERT(mOwner->OnTaskQueue());
       return !mPromise.IsEmpty();
     }
 
     void RejectPromise(MediaDecoderReader::NotDecodedReason aReason,
                        const char* aMethodName) override
     {
       MOZ_ASSERT(mOwner->OnTaskQueue());
       mPromise.Reject(aReason, aMethodName);
       mDecodingRequested = false;
     }
   };
 
-  DecoderDataWithPromise<MediaDataPromise> mAudio;
-  DecoderDataWithPromise<MediaDataPromise> mVideo;
+  DecoderDataWithPromise mAudio;
+  DecoderDataWithPromise mVideo;
 
   // Returns true when the decoder for this track needs input.
   bool NeedInput(DecoderData& aDecoder);
 
   DecoderData& GetDecoderData(TrackType aTrack);
 
   // Demuxer objects.
   RefPtr<MediaDataDemuxer> mDemuxer;