Bug 1135785 - Introduce a 1-argument overload of ProxyMediaCall. r=cpearce

This commit is contained in:
Bobby Holley 2015-02-22 13:56:53 -08:00
Родитель a0678bc6cb
Коммит 206603a7ab
1 изменённых файлов: 22 добавлений и 2 удалений

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

@ -591,7 +591,19 @@ protected:
Type mMethod;
};
// NB: MethodCallWithOneArg definition should go here, if/when it is needed.
template<typename PromiseType, typename ThisType, typename Arg1Type>
class MethodCallWithOneArg : public MethodCallBase<PromiseType>
{
public:
typedef nsRefPtr<PromiseType>(ThisType::*Type)(Arg1Type);
MethodCallWithOneArg(ThisType* aThisVal, Type aMethod, Arg1Type aArg1)
: mThisVal(aThisVal), mMethod(aMethod), mArg1(aArg1) {}
nsRefPtr<PromiseType> Invoke() MOZ_OVERRIDE { return ((*mThisVal).*mMethod)(mArg1); }
protected:
nsRefPtr<ThisType> mThisVal;
Type mMethod;
Arg1Type mArg1;
};
template<typename PromiseType, typename ThisType, typename Arg1Type, typename Arg2Type>
class MethodCallWithTwoArgs : public MethodCallBase<PromiseType>
@ -652,7 +664,15 @@ ProxyMediaCall(TargetType* aTarget, ThisType* aThisVal, const char* aCallerName,
return detail::ProxyInternal(aTarget, methodCall, aCallerName);
}
// NB: One-arg overload should go here, if/when it is needed.
template<typename PromiseType, typename TargetType, typename ThisType, typename Arg1Type>
static nsRefPtr<PromiseType>
ProxyMediaCall(TargetType* aTarget, ThisType* aThisVal, const char* aCallerName,
nsRefPtr<PromiseType>(ThisType::*aMethod)(Arg1Type), Arg1Type aArg1)
{
typedef detail::MethodCallWithOneArg<PromiseType, ThisType, Arg1Type> MethodCallType;
MethodCallType* methodCall = new MethodCallType(aThisVal, aMethod, aArg1);
return detail::ProxyInternal(aTarget, methodCall, aCallerName);
}
template<typename PromiseType, typename TargetType, typename ThisType,
typename Arg1Type, typename Arg2Type>