Bug 1114880 follow-up: Rename MOZ_{STRONG,WEAK}_REF to MOZ_{OWNING,NON_OWNING}_REF
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 23 Dec 2014 21:17:50 -0500
changeset 248801 9e07239decd36a6e7536dcf52b0c34b329b3a765
parent 248800 834d27e2c0256a4a84aff95ff14853562f59b742
child 248802 0ca8b92f0266126091f219543c84a2179c8fcadb
push id698
push userjlund@mozilla.com
push dateMon, 23 Mar 2015 22:08:11 +0000
treeherdermozilla-release@b0c0ae7b02a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1114880
milestone37.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 1114880 follow-up: Rename MOZ_{STRONG,WEAK}_REF to MOZ_{OWNING,NON_OWNING}_REF
ipc/glue/Shmem.h
mfbt/Attributes.h
mfbt/RefPtr.h
mfbt/WeakPtr.h
xpcom/base/AlreadyAddRefed.h
xpcom/base/StaticPtr.h
xpcom/base/nsAutoPtr.h
xpcom/base/nsRefPtr.h
xpcom/build/nsXREAppData.h
xpcom/glue/nsCOMPtr.h
xpcom/glue/nsComponentManagerUtils.h
xpcom/glue/nsHashKeys.h
xpcom/glue/nsIInterfaceRequestorUtils.h
xpcom/glue/nsProxyRelease.cpp
xpcom/glue/nsThreadUtils.h
xpcom/glue/nsWeakReference.cpp
xpcom/glue/nsWeakReference.h
--- a/ipc/glue/Shmem.h
+++ b/ipc/glue/Shmem.h
@@ -260,17 +260,17 @@ private:
       reinterpret_cast<char*>(aSegment->memory()) + aSegment->Size();
     return reinterpret_cast<uint32_t*>(endOfSegment - sizeof(uint32_t));
   }
 
 #else
   void AssertInvariants() const;
 #endif
 
-  SharedMemory* MOZ_WEAK_REF mSegment;
+  SharedMemory* MOZ_NON_OWNING_REF mSegment;
   void* mData;
   size_t mSize;
   id_t mId;
 };
 
 
 } // namespace ipc
 } // namespace mozilla
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -507,21 +507,21 @@
  *   value is allocated on the heap, and will as a result check such allocations
  *   during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking.
  * MOZ_IMPLICIT: Applies to constructors. Implicit conversion constructors
  *   are disallowed by default unless they are marked as MOZ_IMPLICIT. This
  *   attribute must be used for constructors which intend to provide implicit
  *   conversions.
  * MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT: Applies to functions. Makes it a compile
  *   time error to pass arithmetic expressions on variables to the function.
- * MOZ_STRONG_REF: Applies to declarations of pointer types.  This attribute
+ * MOZ_OWNING_REF: Applies to declarations of pointer types.  This attribute
  *   tells the compiler that the raw pointer is a strong reference, and that
  *   property is somehow enforced by the code.  This can make the compiler
  *   ignore these pointers when validating the usage of pointers otherwise.
- * MOZ_WEAK_REF: Applies to declarations of pointer types.  This attribute
+ * MOZ_NON_OWNING_REF: Applies to declarations of pointer types.  This attribute
  *   tells the compiler that the raw pointer is a weak reference, and that
  *   property is somehow enforced by the code.  This can make the compiler
  *   ignore these pointers when validating the usage of pointers otherwise.
  */
 #ifdef MOZ_CLANG_PLUGIN
 #  define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
 #  define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
 #  define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
@@ -530,18 +530,18 @@
      /* in debug builds, these classes do have non-trivial constructors. */
 #    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
 #  else
 #    define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \
             MOZ_TRIVIAL_CTOR_DTOR
 #  endif
 #  define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
 #  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
-#  define MOZ_STRONG_REF __attribute__((annotate("moz_strong_ref")))
-#  define MOZ_WEAK_REF __attribute__((annotate("moz_weak_ref")))
+#  define MOZ_OWNING_REF __attribute__((annotate("moz_strong_ref")))
+#  define MOZ_NON_OWNING_REF __attribute__((annotate("moz_weak_ref")))
 /*
  * It turns out that clang doesn't like void func() __attribute__ {} without a
  * warning, so use pragmas to disable the warning. This code won't work on GCC
  * anyways, so the warning is safe to ignore.
  */
 #  define MOZ_HEAP_ALLOCATOR \
     _Pragma("clang diagnostic push") \
     _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
@@ -551,18 +551,18 @@
 #  define MOZ_MUST_OVERRIDE /* nothing */
 #  define MOZ_STACK_CLASS /* nothing */
 #  define MOZ_NONHEAP_CLASS /* nothing */
 #  define MOZ_TRIVIAL_CTOR_DTOR /* nothing */
 #  define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */
 #  define MOZ_IMPLICIT /* nothing */
 #  define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */
 #  define MOZ_HEAP_ALLOCATOR /* nothing */
-#  define MOZ_STRONG_REF /* nothing */
-#  define MOZ_WEAK_REF /* nothing */
+#  define MOZ_OWNING_REF /* nothing */
+#  define MOZ_NON_OWNING_REF /* nothing */
 #endif /* MOZ_CLANG_PLUGIN */
 
 /*
  * MOZ_THIS_IN_INITIALIZER_LIST is used to avoid a warning when we know that
  * it's safe to use 'this' in an initializer list.
  */
 #ifdef _MSC_VER
 #  define MOZ_THIS_IN_INITIALIZER_LIST() \
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -280,17 +280,17 @@ public:
 
 private:
   void assign(T* aVal)
   {
     unref(mPtr);
     mPtr = aVal;
   }
 
-  T* MOZ_STRONG_REF mPtr;
+  T* MOZ_OWNING_REF mPtr;
 
   static MOZ_ALWAYS_INLINE T* ref(T* aVal)
   {
     if (aVal) {
       aVal->AddRef();
     }
     return aVal;
   }
@@ -331,17 +331,17 @@ public:
     T* tmp = mPtr;
     mPtr = nullptr;
     return tmp;
   }
 
 private:
   TemporaryRef(T* aVal, const DontRef&) : mPtr(aVal) {}
 
-  mutable T* MOZ_STRONG_REF mPtr;
+  mutable T* MOZ_OWNING_REF mPtr;
 
   TemporaryRef() MOZ_DELETE;
   void operator=(const TemporaryRef&) MOZ_DELETE;
 };
 
 /**
  * OutParamRef is a wrapper that tracks a refcounted pointer passed as
  * an outparam argument to a function.  OutParamRef implements COM T**
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -118,17 +118,17 @@ public:
 #undef snprintf
 #endif
 
 private:
   friend class mozilla::SupportsWeakPtr<T>;
 
   void detach() { mPtr = nullptr; }
 
-  T* MOZ_WEAK_REF mPtr;
+  T* MOZ_NON_OWNING_REF mPtr;
 };
 
 } // namespace detail
 
 template <typename T>
 class SupportsWeakPtr
 {
 protected:
--- a/xpcom/base/AlreadyAddRefed.h
+++ b/xpcom/base/AlreadyAddRefed.h
@@ -132,12 +132,12 @@ struct already_AddRefed
   already_AddRefed<U> downcast()
   {
     U* tmp = static_cast<U*>(mRawPtr);
     mRawPtr = nullptr;
     return already_AddRefed<U>(tmp);
   }
 
 private:
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 };
 
 #endif // AlreadyAddRefed_h
--- a/xpcom/base/StaticPtr.h
+++ b/xpcom/base/StaticPtr.h
@@ -136,17 +136,17 @@ private:
   {
     T* oldPtr = mRawPtr;
     mRawPtr = aNewPtr;
     if (oldPtr) {
       oldPtr->Release();
     }
   }
 
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 };
 
 namespace StaticPtr_internal {
 class Zero;
 } // namespace StaticPtr_internal
 
 #define REFLEXIVE_EQUALITY_OPERATORS(type1, type2, eq_fn, ...) \
   template<__VA_ARGS__>                                        \
--- a/xpcom/base/nsAutoPtr.h
+++ b/xpcom/base/nsAutoPtr.h
@@ -55,21 +55,21 @@ private:
     }
 
     operator T*() const
     {
       return mPtr;
     }
 
   private:
-    T* MOZ_WEAK_REF mPtr;
+    T* MOZ_NON_OWNING_REF mPtr;
   };
 
 private:
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 
 public:
   typedef T element_type;
 
   ~nsAutoPtr()
   {
     delete mRawPtr;
   }
@@ -426,17 +426,17 @@ private:
   assign(T* aNewPtr)
   {
     T* oldPtr = mRawPtr;
     mRawPtr = aNewPtr;
     delete [] oldPtr;
   }
 
 private:
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 
 public:
   typedef T element_type;
 
   ~nsAutoArrayPtr()
   {
     delete [] mRawPtr;
   }
@@ -773,17 +773,17 @@ public:
   virtual nsresult NS_FASTCALL operator()(const nsIID& aIID,
                                           void** aResult) const
   {
     nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
                               : NS_ERROR_NULL_POINTER;
     return status;
   }
 private:
-  T* MOZ_WEAK_REF mRawPtr;
+  T* MOZ_NON_OWNING_REF mRawPtr;
 };
 
 template<class T>
 class nsQueryObjectWithError : public nsCOMPtr_helper
 {
 public:
   nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr)
     : mRawPtr(aRawPtr), mErrorPtr(aErrorPtr)
@@ -796,17 +796,17 @@ public:
     nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
                               : NS_ERROR_NULL_POINTER;
     if (mErrorPtr) {
       *mErrorPtr = status;
     }
     return status;
   }
 private:
-  T* MOZ_WEAK_REF mRawPtr;
+  T* MOZ_NON_OWNING_REF mRawPtr;
   nsresult* mErrorPtr;
 };
 
 template<class T>
 inline nsQueryObject<T>
 do_QueryObject(T* aRawPtr)
 {
   return nsQueryObject<T>(aRawPtr);
--- a/xpcom/base/nsRefPtr.h
+++ b/xpcom/base/nsRefPtr.h
@@ -43,17 +43,17 @@ private:
     T* oldPtr = mRawPtr;
     mRawPtr = aNewPtr;
     if (oldPtr) {
       oldPtr->Release();
     }
   }
 
 private:
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 
 public:
   typedef T element_type;
 
   ~nsRefPtr()
   {
     if (mRawPtr) {
       mRawPtr->Release();
--- a/xpcom/build/nsXREAppData.h
+++ b/xpcom/build/nsXREAppData.h
@@ -26,17 +26,17 @@ struct nsXREAppData
    * is maintained.
    */
   uint32_t size;
 
   /**
    * The directory of the application to be run. May be null if the
    * xulrunner and the app are installed into the same directory.
    */
-  nsIFile* MOZ_WEAK_REF directory;
+  nsIFile* MOZ_NON_OWNING_REF directory;
 
   /**
    * The name of the application vendor. This must be ASCII, and is normally
    * mixed-case, e.g. "Mozilla". Optional (may be null), but highly
    * recommended. Must not be the empty string.
    */
   const char* vendor;
 
@@ -88,17 +88,17 @@ struct nsXREAppData
    * Combination of NS_XRE_ prefixed flags (defined below).
    */
   uint32_t flags;
 
   /**
    * The location of the XRE. XRE_main may not be able to figure this out
    * programatically.
    */
-  nsIFile* MOZ_WEAK_REF xreDirectory;
+  nsIFile* MOZ_NON_OWNING_REF xreDirectory;
 
   /**
    * The minimum/maximum compatible XRE version.
    */
   const char* minVersion;
   const char* maxVersion;
 
   /**
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -162,32 +162,32 @@ class MOZ_STACK_CLASS nsQueryInterface M
 {
 public:
   explicit
   nsQueryInterface(nsISupports* aRawPtr) : mRawPtr(aRawPtr) {}
 
   nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const;
 
 private:
-  nsISupports* MOZ_STRONG_REF mRawPtr;
+  nsISupports* MOZ_OWNING_REF mRawPtr;
 };
 
 class nsQueryInterfaceWithError
 {
 public:
   nsQueryInterfaceWithError(nsISupports* aRawPtr, nsresult* aError)
     : mRawPtr(aRawPtr)
     , mErrorPtr(aError)
   {
   }
 
   nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const;
 
 private:
-  nsISupports* MOZ_STRONG_REF mRawPtr;
+  nsISupports* MOZ_OWNING_REF mRawPtr;
   nsresult* mErrorPtr;
 };
 
 inline nsQueryInterface
 do_QueryInterface(nsISupports* aRawPtr)
 {
   return nsQueryInterface(aRawPtr);
 }
@@ -314,17 +314,17 @@ public:
   assign_from_gs_contractid_with_error(const nsGetServiceByContractIDWithError&,
                                        const nsIID&);
   void NS_FASTCALL
   assign_from_helper(const nsCOMPtr_helper&, const nsIID&);
   void** NS_FASTCALL
   begin_assignment();
 
 protected:
-  NS_MAY_ALIAS_PTR(nsISupports) MOZ_STRONG_REF mRawPtr;
+  NS_MAY_ALIAS_PTR(nsISupports) MOZ_OWNING_REF mRawPtr;
 
   void assign_assuming_AddRef(nsISupports* aNewPtr)
   {
     // |AddRef()|ing the new value (before entering this function) before
     // |Release()|ing the old lets us safely ignore the self-assignment case.
     // We must, however, be careful only to |Release()| _after_ doing the
     // assignment, in case the |Release()| leads to our _own_ destruction,
     // which would, in turn, cause an incorrect second |Release()| of our old
@@ -373,17 +373,17 @@ private:
     NSCAP_LOG_ASSIGNMENT(this, aNewPtr);
     NSCAP_LOG_RELEASE(this, oldPtr);
     if (oldPtr) {
       NSCAP_RELEASE(this, oldPtr);
     }
   }
 
 private:
-  T* MOZ_STRONG_REF mRawPtr;
+  T* MOZ_OWNING_REF mRawPtr;
 #endif
 
 public:
   typedef T element_type;
 
 #ifndef NSCAP_FEATURE_USE_BASE
   ~nsCOMPtr()
   {
--- a/xpcom/glue/nsComponentManagerUtils.h
+++ b/xpcom/glue/nsComponentManagerUtils.h
@@ -36,17 +36,17 @@ public:
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
 
 private:
   const nsCID&    mCID;
-  nsISupports* MOZ_WEAK_REF mOuter;
+  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*       mErrorPtr;
 };
 
 class nsCreateInstanceByContractID : public nsCOMPtr_helper
 {
 public:
   nsCreateInstanceByContractID(const char* aContractID, nsISupports* aOuter,
                                nsresult* aErrorPtr)
@@ -55,17 +55,17 @@ public:
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
 
 private:
   const char*   mContractID;
-  nsISupports* MOZ_WEAK_REF mOuter;
+  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*     mErrorPtr;
 };
 
 class nsCreateInstanceFromFactory : public nsCOMPtr_helper
 {
 public:
   nsCreateInstanceFromFactory(nsIFactory* aFactory, nsISupports* aOuter,
                               nsresult* aErrorPtr)
@@ -73,18 +73,18 @@ public:
     , mOuter(aOuter)
     , mErrorPtr(aErrorPtr)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
 
 private:
-  nsIFactory* MOZ_WEAK_REF mFactory;
-  nsISupports* MOZ_WEAK_REF mOuter;
+  nsIFactory* MOZ_NON_OWNING_REF mFactory;
+  nsISupports* MOZ_NON_OWNING_REF mOuter;
   nsresult*     mErrorPtr;
 };
 
 
 inline const nsCreateInstanceByCID
 do_CreateInstance(const nsCID& aCID, nsresult* aError = 0)
 {
   return nsCreateInstanceByCID(aCID, 0, aError);
--- a/xpcom/glue/nsHashKeys.h
+++ b/xpcom/glue/nsHashKeys.h
@@ -380,17 +380,17 @@ public:
   static KeyTypePointer KeyToPointer(KeyType aKey) { return aKey; }
   static PLDHashNumber HashKey(KeyTypePointer aKey)
   {
     return NS_PTR_TO_UINT32(aKey) >> 2;
   }
   enum { ALLOW_MEMMOVE = true };
 
 protected:
-  T* MOZ_WEAK_REF mKey;
+  T* MOZ_NON_OWNING_REF mKey;
 };
 
 /**
  * hashkey wrapper using T* KeyType that sets key to nullptr upon
  * destruction. Relevant only in cases where a memory pointer-scanner
  * like valgrind might get confused about stale references.
  *
  * @see nsTHashtable::EntryType for specification
--- a/xpcom/glue/nsIInterfaceRequestorUtils.h
+++ b/xpcom/glue/nsIInterfaceRequestorUtils.h
@@ -29,17 +29,17 @@ public:
     : mSource(aSource)
     , mErrorPtr(aError)
   {
   }
 
   virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const;
 
 private:
-  nsISupports* MOZ_WEAK_REF mSource;
+  nsISupports* MOZ_NON_OWNING_REF mSource;
   nsresult* mErrorPtr;
 };
 
 inline const nsGetInterface
 do_GetInterface(nsISupports* aSource, nsresult* aError = 0)
 {
   return nsGetInterface(aSource, aError);
 }
--- a/xpcom/glue/nsProxyRelease.cpp
+++ b/xpcom/glue/nsProxyRelease.cpp
@@ -15,17 +15,17 @@ public:
 
   NS_IMETHOD Run()
   {
     mDoomed->Release();
     return NS_OK;
   }
 
 private:
-  nsISupports* MOZ_STRONG_REF mDoomed;
+  nsISupports* MOZ_OWNING_REF mDoomed;
 };
 
 nsresult
 NS_ProxyRelease(nsIEventTarget* aTarget, nsISupports* aDoomed,
                 bool aAlwaysProxy)
 {
   nsresult rv;
 
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -292,17 +292,17 @@ struct nsRunnableMethodReceiver<ClassTyp
   }
   ~nsRunnableMethodReceiver() { Revoke(); }
   void Revoke() { mObj = nullptr; }
 };
 
 template<class ClassType>
 struct nsRunnableMethodReceiver<ClassType, void, false>
 {
-  ClassType* MOZ_WEAK_REF mObj;
+  ClassType* MOZ_NON_OWNING_REF mObj;
   explicit nsRunnableMethodReceiver(ClassType* aObj) : mObj(aObj) {}
   void Revoke() { mObj = nullptr; }
 };
 
 template<typename Method, bool Owning> struct nsRunnableMethodTraits;
 
 template<class C, typename R, typename A, bool Owning>
 struct nsRunnableMethodTraits<R(C::*)(A), Owning>
--- a/xpcom/glue/nsWeakReference.cpp
+++ b/xpcom/glue/nsWeakReference.cpp
@@ -40,17 +40,17 @@ private:
 
   void
   NoticeReferentDestruction()
   // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor.
   {
     mReferent = 0;
   }
 
-  nsSupportsWeakReference* MOZ_WEAK_REF mReferent;
+  nsSupportsWeakReference* MOZ_NON_OWNING_REF mReferent;
 };
 
 nsresult
 nsQueryReferent::operator()(const nsIID& aIID, void** aAnswer) const
 {
   nsresult status;
   if (mWeakPtr) {
     if (NS_FAILED(status = mWeakPtr->QueryReferent(aIID, aAnswer))) {
--- a/xpcom/glue/nsWeakReference.h
+++ b/xpcom/glue/nsWeakReference.h
@@ -26,17 +26,17 @@ protected:
   inline ~nsSupportsWeakReference();
 
 private:
   friend class nsWeakReference;
 
   // Called (only) by an |nsWeakReference| from _its_ dtor.
   void NoticeProxyDestruction() { mProxy = 0; }
 
-  nsWeakReference* MOZ_WEAK_REF mProxy;
+  nsWeakReference* MOZ_NON_OWNING_REF mProxy;
 
 protected:
 
   void ClearWeakReferences();
   bool HasWeakReferences() const { return mProxy != 0; }
 };
 
 inline