Bug 1283032 - initialize members from RunnableMethod in constructor. r?billm
MozReview-Commit-ID: L6tAqI1ci1b
--- a/ipc/glue/TaskFactory.h
+++ b/ipc/glue/TaskFactory.h
@@ -57,40 +57,41 @@ public:
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);
- task->Init(object_, method, base::MakeTuple());
+ RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
+ base::MakeTuple());
+
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);
- task->Init(object_, method, base::MakeTuple(a));
+ RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
+ base::MakeTuple(a));
+
return task.forget();
}
protected:
template <class Method, class Params>
class RunnableMethod : public Runnable {
public:
- RunnableMethod() { }
+ RunnableMethod(T* obj, Method meth, const Params& params)
+ : obj_(obj)
+ , meth_(meth)
+ , params_(params) {
- void Init(T* obj, Method meth, const Params& params) {
- obj_ = obj;
- meth_ = meth;
- params_ = params;
}
NS_IMETHOD Run() override {
DispatchToMethod(obj_, meth_, params_);
return NS_OK;
}
private: