зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
dad9a8cbfb
Коммит
48f5209447
|
@ -68,19 +68,19 @@ public:
|
||||||
Pledge& operator = (const Pledge&) = delete;
|
Pledge& operator = (const Pledge&) = delete;
|
||||||
|
|
||||||
template<typename OnSuccessType>
|
template<typename OnSuccessType>
|
||||||
void Then(OnSuccessType aOnSuccess)
|
void Then(OnSuccessType&& aOnSuccess)
|
||||||
{
|
{
|
||||||
Then(aOnSuccess, [](ErrorType&){});
|
Then(Forward<OnSuccessType>(aOnSuccess), [](ErrorType&){});
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OnSuccessType, typename OnFailureType>
|
template<typename OnSuccessType, typename OnFailureType>
|
||||||
void Then(OnSuccessType aOnSuccess, OnFailureType aOnFailure)
|
void Then(OnSuccessType&& aOnSuccess, OnFailureType&& aOnFailure)
|
||||||
{
|
{
|
||||||
class Functors : public FunctorsBase
|
class Functors : public FunctorsBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Functors(OnSuccessType& aOnSuccess, OnFailureType& aOnFailure)
|
Functors(OnSuccessType&& aOnSuccess, OnFailureType&& aOnFailure)
|
||||||
: mOnSuccess(aOnSuccess), mOnFailure(aOnFailure) {}
|
: mOnSuccess(Move(aOnSuccess)), mOnFailure(Move(aOnFailure)) {}
|
||||||
|
|
||||||
void Succeed(ValueType& result)
|
void Succeed(ValueType& result)
|
||||||
{
|
{
|
||||||
|
@ -94,8 +94,8 @@ public:
|
||||||
OnSuccessType mOnSuccess;
|
OnSuccessType mOnSuccess;
|
||||||
OnFailureType mOnFailure;
|
OnFailureType mOnFailure;
|
||||||
};
|
};
|
||||||
mFunctors = new Functors(aOnSuccess, aOnFailure);
|
mFunctors = new Functors(Forward<OnSuccessType>(aOnSuccess),
|
||||||
|
Forward<OnFailureType>(aOnFailure));
|
||||||
if (mDone) {
|
if (mDone) {
|
||||||
if (!mRejected) {
|
if (!mRejected) {
|
||||||
mFunctors->Succeed(mValue);
|
mFunctors->Succeed(mValue);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче