Bug 1283032 - initialize members from RunnableMethod in constructor. r?billm draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Fri, 01 Jul 2016 16:05:28 +0300
changeset 383157 2c41540e3c58e71d723a5aafa626920be6bde3db
parent 382391 b69a5bbb5e40bd426e35222baa600b481e50d265
child 524408 e65892e3f1e5af913093cafd04cf478a3fc911cd
push id21950
push userbmo:bpostelnicu@mozilla.com
push dateFri, 01 Jul 2016 13:06:01 +0000
reviewersbillm
bugs1283032
milestone50.0a1
Bug 1283032 - initialize members from RunnableMethod in constructor. r?billm MozReview-Commit-ID: L6tAqI1ci1b
ipc/glue/TaskFactory.h
--- 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: