Bug 1361263 - allow InvokeAsync() to accept a member function which is pass-by-reference. r=gerald
authorJW Wang <jwwang@mozilla.com>
Sun, 30 Apr 2017 15:37:19 +0800
changeset 356162 bdc6c6d8065319c8089f7f60c0b72942dea218a4
parent 356126 604acb6a6aece0d9f296dbb7ca091f45713c0c9d
child 356163 20a9d741cdf4a9e88598c8a4471677b834e70927
push id31759
push userkwierso@gmail.com
push dateWed, 03 May 2017 20:18:58 +0000
treeherdermozilla-central@96605941c002 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1361263, 1300476
milestone55.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 1361263 - allow InvokeAsync() to accept a member function which is pass-by-reference. r=gerald StoreCopyPassByRRef<> ensures a copy is stored in the runnable. We don't have to worry about the concern of bug 1300476. MozReview-Commit-ID: DHqlzlVLBFV
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaDecoderStateMachine.cpp
dom/media/mediasource/MediaSourceDemuxer.cpp
xpcom/threads/MozPromise.h
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -65,34 +65,34 @@ MediaDecoderReaderWrapper::RequestVideoD
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   if (aTimeThreshold > media::TimeUnit::Zero()) {
     aTimeThreshold += StartTime();
   }
 
   int64_t startTime = StartTime().ToMicroseconds();
-  return InvokeAsync<bool, media::TimeUnit&&>(
+  return InvokeAsync(
     mReader->OwnerThread(), mReader.get(), __func__,
     &MediaDecoderReader::RequestVideoData,
     aSkipToNextKeyframe, aTimeThreshold)
   ->Then(mOwnerThread, __func__,
          [startTime] (VideoData* aVideo) {
            aVideo->AdjustForStartTime(startTime);
          },
          [] (const MediaResult& aError) {});
 }
 
 RefPtr<MediaDecoderReader::SeekPromise>
 MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   SeekTarget adjustedTarget = aTarget;
   adjustedTarget.SetTime(adjustedTarget.GetTime() + StartTime());
-  return InvokeAsync<SeekTarget&&>(
+  return InvokeAsync(
            mReader->OwnerThread(), mReader.get(), __func__,
            &MediaDecoderReader::Seek,
            Move(adjustedTarget));
 }
 
 RefPtr<MediaDecoderReaderWrapper::WaitForDataPromise>
 MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
 {
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3136,17 +3136,17 @@ MediaDecoderStateMachine::Seek(const See
   MOZ_ASSERT(mDuration.Ref().isSome(), "We should have got duration already");
 
   return mStateObj->HandleSeek(aTarget);
 }
 
 RefPtr<MediaDecoder::SeekPromise>
 MediaDecoderStateMachine::InvokeSeek(const SeekTarget& aTarget)
 {
-  return InvokeAsync<SeekTarget&&>(
+  return InvokeAsync(
            OwnerThread(), this, __func__,
            &MediaDecoderStateMachine::Seek, aTarget);
 }
 
 void MediaDecoderStateMachine::StopMediaSink()
 {
   MOZ_ASSERT(OnTaskQueue());
   if (mMediaSink->IsStarted()) {
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -316,17 +316,17 @@ MediaSourceTrackDemuxer::GetInfo() const
 {
   return mParent->GetTrackInfo(mType)->Clone();
 }
 
 RefPtr<MediaSourceTrackDemuxer::SeekPromise>
 MediaSourceTrackDemuxer::Seek(const TimeUnit& aTime)
 {
   MOZ_ASSERT(mParent, "Called after BreackCycle()");
-  return InvokeAsync<TimeUnit&&>(
+  return InvokeAsync(
            mParent->GetTaskQueue(), this, __func__,
            &MediaSourceTrackDemuxer::DoSeek, aTime);
 }
 
 RefPtr<MediaSourceTrackDemuxer::SamplesPromise>
 MediaSourceTrackDemuxer::GetSamples(int32_t aNumSamples)
 {
   MOZ_ASSERT(mParent, "Called after BreackCycle()");
@@ -360,17 +360,17 @@ MediaSourceTrackDemuxer::GetNextRandomAc
   *aTime = mNextRandomAccessPoint;
   return NS_OK;
 }
 
 RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
 MediaSourceTrackDemuxer::SkipToNextRandomAccessPoint(
   const TimeUnit& aTimeThreshold)
 {
-  return InvokeAsync<TimeUnit&&>(
+  return InvokeAsync(
            mParent->GetTaskQueue(), this, __func__,
            &MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint,
            aTimeThreshold);
 }
 
 media::TimeIntervals
 MediaSourceTrackDemuxer::GetBuffered()
 {
--- a/xpcom/threads/MozPromise.h
+++ b/xpcom/threads/MozPromise.h
@@ -1323,22 +1323,21 @@ template<typename... Storages,
          typename PromiseType, typename ThisType, typename... ArgTypes,
          typename... ActualArgTypes,
          typename EnableIf<sizeof...(Storages) == 0, int>::Type = 0>
 static RefPtr<PromiseType>
 InvokeAsync(AbstractThread* aTarget, ThisType* aThisVal, const char* aCallerName,
             RefPtr<PromiseType>(ThisType::*aMethod)(ArgTypes...),
             ActualArgTypes&&... aArgs)
 {
-  static_assert((!detail::Any(IsReference<ArgTypes>::value...)) &&
-                (!detail::Any(IsPointer<ArgTypes>::value...)),
-                "Cannot pass reference/pointer types through InvokeAsync, Storages must be provided");
+  static_assert(!detail::Any(IsPointer<ArgTypes>::value...),
+                "Cannot pass pointer types through InvokeAsync, Storages must be provided");
   static_assert(sizeof...(ArgTypes) == sizeof...(ActualArgTypes),
                 "Method's ArgTypes and ActualArgTypes should have equal sizes");
-  return detail::InvokeAsyncImpl<StoreCopyPassByRRef<ArgTypes>...>(
+  return detail::InvokeAsyncImpl<StoreCopyPassByRRef<typename Decay<ArgTypes>::Type>...>(
            aTarget, aThisVal, aCallerName, aMethod,
            Forward<ActualArgTypes>(aArgs)...);
 }
 
 namespace detail {
 
 template<typename Function, typename PromiseType>
 class ProxyFunctionRunnable : public CancelableRunnable