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

--HG--
extra : rebase_source : 77f2175611aa6fad88207a771de75fd28fd46f21
extra : source : 429c62928fd43185da45c905a150cfbe84cb3cf7
This commit is contained in:
JW Wang 2017-04-30 15:37:19 +08:00
parent 480b73c38c
commit 47f3443d87
4 changed files with 8 additions and 9 deletions

View File

@ -70,7 +70,7 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
}
int64_t startTime = StartTime().ToMicroseconds();
return InvokeAsync<bool, media::TimeUnit&&>(
return InvokeAsync(
mReader->OwnerThread(), mReader.get(), __func__,
&MediaDecoderReader::RequestVideoData,
aSkipToNextKeyframe, aTimeThreshold)
@ -87,7 +87,7 @@ 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));

View File

@ -3141,7 +3141,7 @@ MediaDecoderStateMachine::Seek(const SeekTarget& aTarget)
RefPtr<MediaDecoder::SeekPromise>
MediaDecoderStateMachine::InvokeSeek(const SeekTarget& aTarget)
{
return InvokeAsync<SeekTarget&&>(
return InvokeAsync(
OwnerThread(), this, __func__,
&MediaDecoderStateMachine::Seek, aTarget);
}

View File

@ -321,7 +321,7 @@ 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);
}
@ -365,7 +365,7 @@ RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
MediaSourceTrackDemuxer::SkipToNextRandomAccessPoint(
const TimeUnit& aTimeThreshold)
{
return InvokeAsync<TimeUnit&&>(
return InvokeAsync(
mParent->GetTaskQueue(), this, __func__,
&MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint,
aTimeThreshold);

View File

@ -1328,12 +1328,11 @@ 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)...);
}