Bug 1123115 - Clarify the ownership of some member variables in task.h; r=bent
authorEhsan Akhgari <ehsan@mozilla.com>
Sun, 18 Jan 2015 14:21:17 -0500
changeset 251930 69cdf42cdaf9eb92eb8da4d170e9239cf38bb811
parent 251929 d8c0fee0015a705ddd5298ce9f9494c36a740466
child 251931 bc297ccecb13cb234745edbabafef99ecd106d40
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1123115
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1123115 - Clarify the ownership of some member variables in task.h; r=bent
ipc/chromium/src/base/task.h
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -192,17 +192,18 @@ class ScopedRunnableMethodFactory : publ
       obj_ = obj;
       meth_ = meth;
       params_ = params;
     }
 
     virtual void Run() { DispatchToMethod(obj_, meth_, params_); }
 
    private:
-    T* obj_;
+    T* MOZ_UNSAFE_REF("The validity of this pointer must be enforced by "
+                      "external factors.") obj_;
     Method meth_;
     Params params_;
 
     DISALLOW_EVIL_CONSTRUCTORS(RunnableMethod);
   };
 
  private:
   T* object_;
@@ -220,34 +221,36 @@ class DeleteTask : public CancelableTask
   }
   virtual void Run() {
     delete obj_;
   }
   virtual void Cancel() {
     obj_ = NULL;
   }
  private:
-  T* obj_;
+  T* MOZ_UNSAFE_REF("The validity of this pointer must be enforced by "
+                    "external factors.") obj_;
 };
 
 // Task to Release() an object
 template<class T>
 class ReleaseTask : public CancelableTask {
  public:
   explicit ReleaseTask(T* obj) : obj_(obj) {
   }
   virtual void Run() {
     if (obj_)
       obj_->Release();
   }
   virtual void Cancel() {
     obj_ = NULL;
   }
  private:
-  T* obj_;
+  T* MOZ_UNSAFE_REF("The validity of this pointer must be enforced by "
+                    "external factors.") obj_;
 };
 
 // RunnableMethodTraits --------------------------------------------------------
 //
 // This traits-class is used by RunnableMethod to manage the lifetime of the
 // callee object.  By default, it is assumed that the callee supports AddRef
 // and Release methods.  A particular class can specialize this template to
 // define other lifetime management.  For example, if the callee is known to
@@ -314,17 +317,19 @@ class RunnableMethod : public Cancelable
  private:
   void ReleaseCallee() {
     if (obj_) {
       RunnableMethodTraits<T>::ReleaseCallee(obj_);
       obj_ = NULL;
     }
   }
 
-  T* obj_;
+  // This is owning because of the RetainCallee and ReleaseCallee calls in the
+  // constructor and destructor.
+  T* MOZ_OWNING_REF obj_;
   Method meth_;
   Params params_;
 };
 
 template <class T, class Method>
 inline CancelableTask* NewRunnableMethod(T* object, Method method) {
   return new RunnableMethod<T, Method, Tuple0>(object, method, MakeTuple());
 }
@@ -508,17 +513,18 @@ inline CancelableTask* NewRunnableFuncti
 // Base for all Callbacks that handles storage of the pointers.
 template <class T, typename Method>
 class CallbackStorage {
  public:
   CallbackStorage(T* obj, Method meth) : obj_(obj), meth_(meth) {
   }
 
  protected:
-  T* obj_;
+  T* MOZ_UNSAFE_REF("The validity of this pointer must be enforced by "
+                    "external factors.") obj_;
   Method meth_;
 };
 
 // Interface that is exposed to the consumer, that does the actual calling
 // of the method.
 template <typename Params>
 class CallbackRunner {
  public: