Bug 1004564 - Move AtomicRefCounted to mozilla::external and outlaw it in Gecko code; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 01 May 2014 14:33:20 -0400
changeset 181288 4cb70de5fd6aea678aa5985a1eb92d4af1eab153
parent 181287 aaff0e8f5af2b100c377ac0f96711a9591acfe88
child 181289 23a646a9ec55afdd050d5d8829ef3d2144ae1ad8
push id6611
push usercbook@mozilla.com
push dateFri, 02 May 2014 12:59:43 +0000
treeherderfx-team@35c124cab3a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1004564
milestone32.0a1
Bug 1004564 - Move AtomicRefCounted to mozilla::external and outlaw it in Gecko code; r=froydnj
mfbt/RefPtr.h
mozglue/linker/ElfLoader.h
mozglue/linker/Zip.h
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -174,30 +174,37 @@ class RefCounted : public detail::RefCou
 {
   public:
     ~RefCounted() {
       static_assert(IsBaseOf<RefCounted, T>::value,
                     "T must derive from RefCounted<T>");
     }
 };
 
+namespace external {
+
 /**
  * AtomicRefCounted<T> is like RefCounted<T>, with an atomically updated
  * reference counter.
+ *
+ * NOTE: Please do not use this class, use NS_INLINE_DECL_THREADSAFE_REFCOUNTING
+ * instead.
  */
 template<typename T>
-class AtomicRefCounted : public detail::RefCounted<T, detail::AtomicRefCount>
+class AtomicRefCounted : public mozilla::detail::RefCounted<T, mozilla::detail::AtomicRefCount>
 {
   public:
     ~AtomicRefCounted() {
       static_assert(IsBaseOf<AtomicRefCounted, T>::value,
                     "T must derive from AtomicRefCounted<T>");
     }
 };
 
+}
+
 /**
  * RefPtr points to a refcounted thing that has AddRef and Release
  * methods to increase/decrease the refcount, respectively.  After a
  * RefPtr<T> is assigned a T*, the T* can be used through the RefPtr
  * as if it were a T*.
  *
  * A RefPtr can forget its underlying T*, which results in the T*
  * being wrapped in a temporary object until the T* is either
--- a/mozglue/linker/ElfLoader.h
+++ b/mozglue/linker/ElfLoader.h
@@ -83,17 +83,17 @@ template <> inline RefCounted<LibHandle,
 
 } /* namespace detail */
 } /* namespace mozilla */
 
 /**
  * Abstract class for loaded libraries. Libraries may be loaded through the
  * system linker or this linker, both cases will be derived from this class.
  */
-class LibHandle: public mozilla::AtomicRefCounted<LibHandle>
+class LibHandle: public mozilla::external::AtomicRefCounted<LibHandle>
 {
 public:
   MOZ_DECLARE_REFCOUNTED_TYPENAME(LibHandle)
   /**
    * Constructor. Takes the path of the loaded library and will store a copy
    * of the leaf name.
    */
   LibHandle(const char *path)
@@ -135,32 +135,32 @@ public:
    * Library handles can be referenced from other library handles or
    * externally (when dlopen()ing using this linker). We need to be
    * able to distinguish between the two kind of referencing for better
    * bookkeeping.
    */
   void AddDirectRef()
   {
     ++directRefCnt;
-    mozilla::AtomicRefCounted<LibHandle>::AddRef();
+    mozilla::external::AtomicRefCounted<LibHandle>::AddRef();
   }
 
   /**
    * Releases a direct reference, and returns whether there are any direct
    * references left.
    */
   bool ReleaseDirectRef()
   {
     bool ret = false;
     if (directRefCnt) {
       MOZ_ASSERT(directRefCnt <=
-                 mozilla::AtomicRefCounted<LibHandle>::refCount());
+                 mozilla::external::AtomicRefCounted<LibHandle>::refCount());
       if (--directRefCnt)
         ret = true;
-      mozilla::AtomicRefCounted<LibHandle>::Release();
+      mozilla::external::AtomicRefCounted<LibHandle>::Release();
     }
     return ret;
   }
 
   /**
    * Returns the number of direct references
    */
   MozRefCountType DirectRefCount()
--- a/mozglue/linker/Zip.h
+++ b/mozglue/linker/Zip.h
@@ -21,17 +21,17 @@ class ZipCollection;
  * Class to handle access to Zip archive streams. The Zip archive is mapped
  * in memory, and streams are direct references to that mapped memory.
  * Zip files are assumed to be correctly formed. No boundary checks are
  * performed, which means hand-crafted malicious Zip archives can make the
  * code fail in bad ways. However, since the only intended use is to load
  * libraries from Zip archives, there is no interest in making this code
  * safe, since the libraries could contain malicious code anyways.
  */
-class Zip: public mozilla::AtomicRefCounted<Zip>
+class Zip: public mozilla::external::AtomicRefCounted<Zip>
 {
 public:
   MOZ_DECLARE_REFCOUNTED_TYPENAME(Zip)
   /**
    * Create a Zip instance for the given file name. Returns nullptr in case
    * of failure.
    */
   static mozilla::TemporaryRef<Zip> Create(const char *filename);