Bug 1207245 - part 4 - remove RefPtr.h; r=ehsan
☠☠ backed out by 9f660e994268 ☠ ☠
authorNathan Froyd <froydnj@mozilla.com>
Wed, 07 Oct 2015 15:25:11 -0400
changeset 299736 ddcc0549128223e8e4f6184430352d456a6a0802
parent 299735 1f51d1614b9a58e41dd3a1bf2dc6aad34dbb2170
child 299737 93828e13ad6374606ac8bf0296268e91e86f9eea
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1207245
milestone44.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 1207245 - part 4 - remove RefPtr.h; r=ehsan It has been superseded by the availability of nsRefPtr.h.
gfx/layers/AtomicRefCountedWithFinalize.h
mfbt/RefCounted.h
mfbt/RefPtr.h
mfbt/moz.build
mfbt/nsRefPtr.h
--- a/gfx/layers/AtomicRefCountedWithFinalize.h
+++ b/gfx/layers/AtomicRefCountedWithFinalize.h
@@ -57,19 +57,16 @@ protected:
 
     static void DestroyToBeCalledOnMainThread(T* ptr) {
       MOZ_ASSERT(NS_IsMainThread());
       delete ptr;
     }
 
 public:
     // Mark user classes that are considered flawless.
-    template<typename U>
-    friend class RefPtr;
-
     template<class U>
     friend class ::mozilla::StaticRefPtr;
 
     template<class U>
     friend class ::nsRefPtr;
 
     template<class U>
     friend struct ::RunnableMethodTraits;
--- a/mfbt/RefCounted.h
+++ b/mfbt/RefCounted.h
@@ -24,18 +24,16 @@
 #if defined(MOZILLA_INTERNAL_API) && \
     !defined(MOZILLA_XPCOMRT_API) && \
     (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
 #define MOZ_REFCOUNTED_LEAK_CHECKING
 #endif
 
 namespace mozilla {
 
-template<typename T> class RefPtr;
-
 /**
  * RefCounted<T> is a sort of a "mixin" for a class T.  RefCounted
  * manages, well, refcounting for T, and because RefCounted is
  * parameterized on T, RefCounted<T> can call T's destructor directly.
  * This means T doesn't need to have a virtual dtor and so doesn't
  * need a vtable.
  *
  * RefCounted<T> is created with refcount == 0.  Newly-allocated
@@ -87,18 +85,16 @@ enum RefCountAtomicity
 {
   AtomicRefCount,
   NonAtomicRefCount
 };
 
 template<typename T, RefCountAtomicity Atomicity>
 class RefCounted
 {
-  friend class RefPtr<T>;
-
 protected:
   RefCounted() : mRefCnt(0) {}
   ~RefCounted() { MOZ_ASSERT(mRefCnt == detail::DEAD); }
 
 public:
   // Compatibility with nsRefPtr.
   void AddRef() const
   {
deleted file mode 100644
--- a/mfbt/RefPtr.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Helpers for defining and using refcounted objects. */
-
-#ifndef mozilla_RefPtr_h
-#define mozilla_RefPtr_h
-
-#include "mozilla/AlreadyAddRefed.h"
-#include "mozilla/Assertions.h"
-#include "mozilla/Atomics.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/Move.h"
-#include "mozilla/RefCounted.h"
-#include "mozilla/RefCountType.h"
-#include "mozilla/nsRefPtr.h"
-#include "mozilla/TypeTraits.h"
-#if defined(MOZILLA_INTERNAL_API)
-#include "nsXPCOM.h"
-#endif
-
-#if defined(MOZILLA_INTERNAL_API) && \
-    !defined(MOZILLA_XPCOMRT_API) && \
-    (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING))
-#define MOZ_REFCOUNTED_LEAK_CHECKING
-#endif
-
-namespace mozilla {
-
-template<typename T> class OutParamRef;
-template<typename T> OutParamRef<T> byRef(RefPtr<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
- * re-adopted from or released by the temporary.
- */
-template<typename T>
-class RefPtr
-{
-  // To allow them to use unref()
-  friend class OutParamRef<T>;
-
-  struct DontRef {};
-
-public:
-  RefPtr() : mPtr(0) {}
-  RefPtr(const RefPtr& aOther) : mPtr(ref(aOther.mPtr)) {}
-  MOZ_IMPLICIT RefPtr(already_AddRefed<T>& aOther) : mPtr(aOther.take()) {}
-  MOZ_IMPLICIT RefPtr(already_AddRefed<T>&& aOther) : mPtr(aOther.take()) {}
-  MOZ_IMPLICIT RefPtr(T* aVal) : mPtr(ref(aVal)) {}
-
-  template<typename U>
-  MOZ_IMPLICIT RefPtr(const RefPtr<U>& aOther) : mPtr(ref(aOther.get())) {}
-
-  ~RefPtr() { unref(mPtr); }
-
-  RefPtr& operator=(const RefPtr& aOther)
-  {
-    assign(ref(aOther.mPtr));
-    return *this;
-  }
-  RefPtr& operator=(already_AddRefed<T>& aOther)
-  {
-    assign(aOther.take());
-    return *this;
-  }
-  RefPtr& operator=(already_AddRefed<T>&& aOther)
-  {
-    assign(aOther.take());
-    return *this;
-  }
-  RefPtr& operator=(T* aVal)
-  {
-    assign(ref(aVal));
-    return *this;
-  }
-
-  template<typename U>
-  RefPtr& operator=(const RefPtr<U>& aOther)
-  {
-    assign(ref(aOther.get()));
-    return *this;
-  }
-
-  already_AddRefed<T> forget()
-  {
-    T* tmp = mPtr;
-    mPtr = nullptr;
-    return already_AddRefed<T>(tmp);
-  }
-
-  T* get() const { return mPtr; }
-  operator T*() const
-#ifdef MOZ_HAVE_REF_QUALIFIERS
-  &
-#endif
-  { return mPtr; }
-  T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mPtr; }
-  T& operator*() const { return *mPtr; }
-
-#ifdef MOZ_HAVE_REF_QUALIFIERS
-  // Don't allow implicit conversion of temporary RefPtr to raw pointer, because
-  // the refcount might be one and the pointer will immediately become invalid.
-  operator T*() const && = delete;
-
-  // Needed to avoid the deleted operator above
-  explicit operator bool() const { return !!mPtr; }
-#endif
-
-private:
-  void assign(T* aVal)
-  {
-    T* tmp = mPtr;
-    mPtr = aVal;
-    unref(tmp);
-  }
-
-  T* MOZ_OWNING_REF mPtr;
-
-  static MOZ_ALWAYS_INLINE T* ref(T* aVal)
-  {
-    if (aVal) {
-      aVal->AddRef();
-    }
-    return aVal;
-  }
-
-  static MOZ_ALWAYS_INLINE void unref(T* aVal)
-  {
-    if (aVal) {
-      aVal->Release();
-    }
-  }
-};
-
-/**
- * OutParamRef is a wrapper that tracks a refcounted pointer passed as
- * an outparam argument to a function.  OutParamRef implements COM T**
- * outparam semantics: this requires the callee to AddRef() the T*
- * returned through the T** outparam on behalf of the caller.  This
- * means the caller (through OutParamRef) must Release() the old
- * object contained in the tracked RefPtr.  It's OK if the callee
- * returns the same T* passed to it through the T** outparam, as long
- * as the callee obeys the COM discipline.
- *
- * Prefer returning already_AddRefed<T> from functions over creating T**
- * outparams and passing OutParamRef<T> to T**.  Prefer RefPtr<T>*
- * outparams over T** outparams.
- */
-template<typename T>
-class OutParamRef
-{
-  friend OutParamRef byRef<T>(RefPtr<T>&);
-
-public:
-  ~OutParamRef()
-  {
-    RefPtr<T>::unref(mRefPtr.mPtr);
-    mRefPtr.mPtr = mTmp;
-  }
-
-  operator T**() { return &mTmp; }
-
-private:
-  explicit OutParamRef(RefPtr<T>& p) : mRefPtr(p), mTmp(p.get()) {}
-
-  RefPtr<T>& mRefPtr;
-  T* mTmp;
-
-  OutParamRef() = delete;
-  OutParamRef& operator=(const OutParamRef&) = delete;
-};
-
-/**
- * byRef cooperates with OutParamRef to implement COM outparam semantics.
- */
-template<typename T>
-OutParamRef<T>
-byRef(RefPtr<T>& aPtr)
-{
-  return OutParamRef<T>(aPtr);
-}
-
-} // namespace mozilla
-
-// Declared in nsRefPtr.h
-template<class T> template<class U>
-nsRefPtr<T>::nsRefPtr(mozilla::RefPtr<U>&& aOther)
-  : nsRefPtr(aOther.forget())
-{
-}
-
-template<class T> template<class U>
-nsRefPtr<T>&
-nsRefPtr<T>::operator=(mozilla::RefPtr<U>&& aOther)
-{
-  assign_assuming_AddRef(aOther.forget().take());
-  return *this;
-}
-
-#endif /* mozilla_RefPtr_h */
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -65,17 +65,16 @@ EXPORTS.mozilla = [
     'PodOperations.h',
     'Poison.h',
     'Range.h',
     'RangedArray.h',
     'RangedPtr.h',
     'RefCounted.h',
     'RefCountType.h',
     'ReentrancyGuard.h',
-    'RefPtr.h',
     'ReverseIterator.h',
     'RollingMean.h',
     'Scoped.h',
     'ScopeExit.h',
     'SegmentedVector.h',
     'SHA1.h',
     'SizePrintfMacros.h',
     'Snprintf.h',
--- a/mfbt/nsRefPtr.h
+++ b/mfbt/nsRefPtr.h
@@ -14,17 +14,16 @@
 /*****************************************************************************/
 
 // template <class T> class nsRefPtrGetterAddRefs;
 
 class nsCOMPtr_helper;
 
 namespace mozilla {
 template<class T> class OwningNonNull;
-template<class T> class RefPtr;
 } // namespace mozilla
 
 template <class T>
 class nsRefPtr
 {
 private:
   void
   assign_with_AddRef(T* aRawPtr)
@@ -123,20 +122,16 @@ public:
   }
 
   MOZ_IMPLICIT nsRefPtr(const nsCOMPtr_helper& aHelper);
 
   // Defined in OwningNonNull.h
   template<class U>
   MOZ_IMPLICIT nsRefPtr(const mozilla::OwningNonNull<U>& aOther);
 
-  // Defined in RefPtr.h
-  template<class U>
-  MOZ_IMPLICIT nsRefPtr(mozilla::RefPtr<U>&& aOther);
-
   // Assignment operators
 
   nsRefPtr<T>&
   operator=(const nsRefPtr<T>& aRhs)
   // copy assignment operator
   {
     assign_with_AddRef(aRhs.mRawPtr);
     return *this;
@@ -187,21 +182,16 @@ public:
     return *this;
   }
 
   // Defined in OwningNonNull.h
   template<class U>
   nsRefPtr<T>&
   operator=(const mozilla::OwningNonNull<U>& aOther);
 
-  // Defined in RefPtr.h
-  template<class U>
-  nsRefPtr<T>&
-  operator=(mozilla::RefPtr<U>&& aOther);
-
   // Other pointer operators
 
   void
   swap(nsRefPtr<T>& aRhs)
   // ...exchange ownership with |aRhs|; can save a pair of refcount operations
   {
     T* temp = aRhs.mRawPtr;
     aRhs.mRawPtr = mRawPtr;