Bug 1343639 - Allow TaskFactory::NewRunnableMethod pass an arbitrary number of arguments to the runnable. r?billm
MozReview-Commit-ID: LXs6urqSxX9
--- a/ipc/glue/TaskFactory.h
+++ b/ipc/glue/TaskFactory.h
@@ -53,32 +53,26 @@ public:
inline already_AddRefed<TaskParamType> NewTask(Args&&... args)
{
typedef TaskWrapper<TaskParamType> TaskWrapper;
RefPtr<TaskWrapper> task =
new TaskWrapper(this, mozilla::Forward<Args>(args)...);
return task.forget();
}
- template <class Method>
- inline already_AddRefed<Runnable> NewRunnableMethod(Method method) {
- typedef TaskWrapper<RunnableMethod<Method, Tuple0> > TaskWrapper;
-
- RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
- base::MakeTuple());
+ template <class Method, typename... Args>
+ inline already_AddRefed<Runnable>
+ NewRunnableMethod(Method method, Args&&... args) {
+ typedef decltype(base::MakeTuple(mozilla::Forward<Args>(args)...)) ArgTuple;
+ typedef RunnableMethod<Method, ArgTuple> RunnableMethod;
+ typedef TaskWrapper<RunnableMethod> TaskWrapper;
- return task.forget();
- }
-
- template <class Method, class A>
- inline already_AddRefed<Runnable> NewRunnableMethod(Method method, const A& a) {
- typedef TaskWrapper<RunnableMethod<Method, Tuple1<A> > > TaskWrapper;
-
- RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
- base::MakeTuple(a));
+ RefPtr<TaskWrapper> task =
+ new TaskWrapper(this, object_, method,
+ base::MakeTuple(mozilla::Forward<Args>(args)...));
return task.forget();
}
protected:
template <class Method, class Params>
class RunnableMethod : public Runnable {
public: