Bug 1213738 - media::Pledge.Then() moves lambda args instead of copying them. r=jesup

--HG--
extra : transplant_source : X%BAyz%A1%BBD%03%3D%21Tv%C7%3E%CFT%02%D0%5D%85
This commit is contained in:
Jan-Ivar Bruaroey 2015-10-13 14:34:54 -04:00
Родитель dad9a8cbfb
Коммит 48f5209447
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -68,19 +68,19 @@ public:
Pledge& operator = (const Pledge&) = delete;
template<typename OnSuccessType>
void Then(OnSuccessType aOnSuccess)
void Then(OnSuccessType&& aOnSuccess)
{
Then(aOnSuccess, [](ErrorType&){});
Then(Forward<OnSuccessType>(aOnSuccess), [](ErrorType&){});
}
template<typename OnSuccessType, typename OnFailureType>
void Then(OnSuccessType aOnSuccess, OnFailureType aOnFailure)
void Then(OnSuccessType&& aOnSuccess, OnFailureType&& aOnFailure)
{
class Functors : public FunctorsBase
{
public:
Functors(OnSuccessType& aOnSuccess, OnFailureType& aOnFailure)
: mOnSuccess(aOnSuccess), mOnFailure(aOnFailure) {}
Functors(OnSuccessType&& aOnSuccess, OnFailureType&& aOnFailure)
: mOnSuccess(Move(aOnSuccess)), mOnFailure(Move(aOnFailure)) {}
void Succeed(ValueType& result)
{
@ -94,8 +94,8 @@ public:
OnSuccessType mOnSuccess;
OnFailureType mOnFailure;
};
mFunctors = new Functors(aOnSuccess, aOnFailure);
mFunctors = new Functors(Forward<OnSuccessType>(aOnSuccess),
Forward<OnFailureType>(aOnFailure));
if (mDone) {
if (!mRejected) {
mFunctors->Succeed(mValue);