Bug 967364: Privatize already_AddRefed::mRawPtr. r=bsmedberg
authorKyle Huey <khuey@kylehuey.com>
Sat, 15 Mar 2014 12:00:15 -0700
changeset 191989 49dfebffbf8e300cf0c63d3040905add42576274
parent 191988 4d78ec7d6f0d6ecbde1d85f6e81e619ae7286971
child 191990 ff034c181ae4520eca6b8eba4156f60d632bcb2a
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs967364
milestone30.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 967364: Privatize already_AddRefed::mRawPtr. r=bsmedberg
xpcom/base/nsAutoPtr.h
xpcom/glue/nsCOMPtr.h
--- a/xpcom/base/nsAutoPtr.h
+++ b/xpcom/base/nsAutoPtr.h
@@ -921,17 +921,17 @@ class nsRefPtr
           // construct from a raw pointer (of the right type)
         {
           if ( mRawPtr )
             mRawPtr->AddRef();
         }
 
       template <typename I>
       nsRefPtr( const already_AddRefed<I>& aSmartPtr )
-            : mRawPtr(aSmartPtr.mRawPtr)
+            : mRawPtr(aSmartPtr.take())
           // construct from |dont_AddRef(expr)|
         {
         }
 
       nsRefPtr( const nsCOMPtr_helper& helper )
         {
           void* newRawPtr;
           if (NS_FAILED(helper(NS_GET_TEMPLATE_IID(T), &newRawPtr)))
@@ -957,17 +957,17 @@ class nsRefPtr
           return *this;
         }
 
       template <typename I>
       nsRefPtr<T>&
       operator=( const already_AddRefed<I>& rhs )
           // assign from |dont_AddRef(expr)|
         {
-          assign_assuming_AddRef(rhs.mRawPtr);
+          assign_assuming_AddRef(rhs.take());
           return *this;
         }
 
       nsRefPtr<T>&
       operator=( const nsCOMPtr_helper& helper )
         {
           void* newRawPtr;
           if (NS_FAILED(helper(NS_GET_TEMPLATE_IID(T), &newRawPtr)))
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -202,16 +202,17 @@ struct already_AddRefed
     template<class U>
     already_AddRefed<U> downcast()
     {
       U* tmp = static_cast<U*>(mRawPtr);
       mRawPtr = nullptr;
       return already_AddRefed<U>(tmp);
     }
 
+  private:
     T* mRawPtr;
   };
 
 template <class T>
 inline
 const already_AddRefed<T>
 dont_AddRef( T* aRawPtr )
   {
@@ -549,32 +550,32 @@ class nsCOMPtr MOZ_FINAL
         {
           if ( mRawPtr )
             NSCAP_ADDREF(this, mRawPtr);
           NSCAP_LOG_ASSIGNMENT(this, aRawPtr);
           NSCAP_ASSERT_NO_QUERY_NEEDED();
         }
 
       nsCOMPtr( const already_AddRefed<T>& aSmartPtr )
-            : NSCAP_CTOR_BASE(aSmartPtr.mRawPtr)
+            : NSCAP_CTOR_BASE(aSmartPtr.take())
           // construct from |dont_AddRef(expr)|
         {
-          NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr);
+          NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
           NSCAP_ASSERT_NO_QUERY_NEEDED();
         }
 
       template<typename U>
       nsCOMPtr( const already_AddRefed<U>& aSmartPtr )
-            : NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.mRawPtr))
+            : NSCAP_CTOR_BASE(static_cast<T*>(aSmartPtr.take()))
           // construct from |dont_AddRef(expr)|
         {
           // But make sure that U actually inherits from T
           static_assert(mozilla::IsBaseOf<T, U>::value,
                         "U is not a subclass of T");
-          NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(aSmartPtr.mRawPtr));
+          NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(mRawPtr));
           NSCAP_ASSERT_NO_QUERY_NEEDED();
         }
 
       nsCOMPtr( const nsQueryInterface qi )
             : NSCAP_CTOR_BASE(0)
           // construct from |do_QueryInterface(expr)|
         {
           NSCAP_LOG_ASSIGNMENT(this, 0);
@@ -654,17 +655,17 @@ class nsCOMPtr MOZ_FINAL
       template<typename U>
       nsCOMPtr<T>&
       operator=( const already_AddRefed<U>& rhs )
           // assign from |dont_AddRef(expr)|
         {
           // Make sure that U actually inherits from T
           static_assert(mozilla::IsBaseOf<T, U>::value,
                         "U is not a subclass of T");
-          assign_assuming_AddRef(static_cast<T*>(rhs.mRawPtr));
+          assign_assuming_AddRef(static_cast<T*>(rhs.take()));
           NSCAP_ASSERT_NO_QUERY_NEEDED();
           return *this;
         }
 
       nsCOMPtr<T>&
       operator=( const nsQueryInterface rhs )
           // assign from |do_QueryInterface(expr)|
         {
@@ -890,20 +891,20 @@ class nsCOMPtr<nsISupports>
           // construct from a raw pointer (of the right type)
         {
           if ( mRawPtr )
             NSCAP_ADDREF(this, mRawPtr);
           NSCAP_LOG_ASSIGNMENT(this, aRawPtr);
         }
 
       nsCOMPtr( const already_AddRefed<nsISupports>& aSmartPtr )
-            : nsCOMPtr_base(aSmartPtr.mRawPtr)
+            : nsCOMPtr_base(aSmartPtr.take())
           // construct from |dont_AddRef(expr)|
         {
-          NSCAP_LOG_ASSIGNMENT(this, aSmartPtr.mRawPtr);
+          NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
         }
 
       nsCOMPtr( const nsQueryInterface qi )
             : nsCOMPtr_base(0)
           // assign from |do_QueryInterface(expr)|
         {
           NSCAP_LOG_ASSIGNMENT(this, 0);
           assign_from_qi(qi, NS_GET_IID(nsISupports));
@@ -976,17 +977,17 @@ class nsCOMPtr<nsISupports>
           assign_with_AddRef(rhs);
           return *this;
         }
 
       nsCOMPtr<nsISupports>&
       operator=( const already_AddRefed<nsISupports>& rhs )
           // assign from |dont_AddRef(expr)|
         {
-          assign_assuming_AddRef(rhs.mRawPtr);
+          assign_assuming_AddRef(rhs.take());
           return *this;
         }
 
       nsCOMPtr<nsISupports>&
       operator=( const nsQueryInterface rhs )
           // assign from |do_QueryInterface(expr)|
         {
           assign_from_qi(rhs, NS_GET_IID(nsISupports));