Bug 1189369, part 2 - Don't implicitly convert nsMaybeWeakPtr to an nsCOMPtr. r=mak
authorAndrew McCreight <continuation@gmail.com>
Tue, 04 Aug 2015 13:55:01 -0700
changeset 287855 25131573fd45d83e1d462ff78d2d5d28a2e5a464
parent 287854 ab292e72b0f3fe5cfa88b510116f58cc690d95ad
child 287856 0182ea87c203f51b64a92f8616701f989ae62201
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1189369
milestone42.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 1189369, part 2 - Don't implicitly convert nsMaybeWeakPtr to an nsCOMPtr. r=mak This is only used in a few places, and it obscures what is happening.
toolkit/components/places/nsMaybeWeakPtr.h
toolkit/components/places/nsNavBookmarks.cpp
toolkit/components/places/nsNavHistory.cpp
--- a/toolkit/components/places/nsMaybeWeakPtr.h
+++ b/toolkit/components/places/nsMaybeWeakPtr.h
@@ -31,20 +31,18 @@ public:
   MOZ_IMPLICIT nsMaybeWeakPtr(nsISupports *ref) { mPtr = ref; }
   MOZ_IMPLICIT nsMaybeWeakPtr(const nsCOMPtr<nsIWeakReference> &ref) { mPtr = ref; }
   MOZ_IMPLICIT nsMaybeWeakPtr(const nsCOMPtr<T> &ref) { mPtr = ref; }
 
   bool operator==(const nsMaybeWeakPtr<T> &other) const {
     return mPtr == other.mPtr;
   }
 
-  operator const nsCOMPtr<T>() const { return GetValue(); }
+  nsISupports* GetRawValue() const { return mPtr.get(); }
 
-  nsISupports* GetRawValue() const { return mPtr.get(); }
-protected:
   const nsCOMPtr<T> GetValue() const {
     return nsCOMPtr<T>(dont_AddRef(static_cast<T*>
                                               (GetValueAs(NS_GET_TEMPLATE_IID(T)))));
   }
 };
 
 // nsMaybeWeakPtrArray is an array of MaybeWeakPtr objects, that knows how to
 // grab a weak reference to a given object if requested.  It only allows a
@@ -94,14 +92,14 @@ ImplCycleCollectionTraverse(nsCycleColle
   }
 }
 
 // Call a method on each element in the array, but only if the element is
 // non-null.
 
 #define ENUMERATE_WEAKARRAY(array, type, method)                           \
   for (uint32_t array_idx = 0; array_idx < array.Length(); ++array_idx) {  \
-    const nsCOMPtr<type> &e = array.ElementAt(array_idx);                  \
+    const nsCOMPtr<type> &e = array.ElementAt(array_idx).GetValue();       \
     if (e)                                                                 \
       e->method;                                                           \
   }
 
 #endif
--- a/toolkit/components/places/nsNavBookmarks.cpp
+++ b/toolkit/components/places/nsNavBookmarks.cpp
@@ -2531,17 +2531,17 @@ nsNavBookmarks::GetObservers(uint32_t* _
 
   nsCOMArray<nsINavBookmarkObserver> observers;
 
   // First add the category cache observers.
   mCacheObservers.GetEntries(observers);
 
   // Then add the other observers.
   for (uint32_t i = 0; i < mObservers.Length(); ++i) {
-    const nsCOMPtr<nsINavBookmarkObserver> &observer = mObservers.ElementAt(i);
+    const nsCOMPtr<nsINavBookmarkObserver> &observer = mObservers.ElementAt(i).GetValue();
     // Skip nullified weak observers.
     if (observer)
       observers.AppendElement(observer);
   }
 
   if (observers.Count() == 0)
     return NS_OK;
 
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -2276,17 +2276,17 @@ nsNavHistory::GetObservers(uint32_t* _co
 
   nsCOMArray<nsINavHistoryObserver> observers;
 
   // First add the category cache observers.
   mCacheObservers.GetEntries(observers);
 
   // Then add the other observers.
   for (uint32_t i = 0; i < mObservers.Length(); ++i) {
-    const nsCOMPtr<nsINavHistoryObserver> &observer = mObservers.ElementAt(i);
+    const nsCOMPtr<nsINavHistoryObserver> &observer = mObservers.ElementAt(i).GetValue();
     // Skip nullified weak observers.
     if (observer)
       observers.AppendElement(observer);
   }
 
   if (observers.Count() == 0)
     return NS_OK;