Backed out changeset 4dce0b1b22af (bug 1425930) for causing build bustage on a CLOSED TREE
authorCoroiu Cristina <ccoroiu@mozilla.com>
Sun, 20 May 2018 23:16:12 +0300
changeset 419117 b19af5ec19d98a3a0ccfd5244a01f95c94162edf
parent 419116 724b88e1831d618572ae70d9c6a8ae67171a5669
child 419118 ad12df88c16e7e65c7f44a1fbe1f1ee6cb17c0a6
push id34026
push userapavel@mozilla.com
push dateMon, 21 May 2018 09:47:33 +0000
treeherdermozilla-central@dc1868d255be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1425930
milestone62.0a1
backs out4dce0b1b22af0eaaa01030de35c97cd3af473305
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
Backed out changeset 4dce0b1b22af (bug 1425930) for causing build bustage on a CLOSED TREE
xpcom/ds/Observer.h
--- a/xpcom/ds/Observer.h
+++ b/xpcom/ds/Observer.h
@@ -52,50 +52,32 @@ public:
   }
 
   /**
    * Remove the observer from the observer list.
    * @return Whether the observer has been found in the list.
    */
   bool RemoveObserver(Observer<T>* aObserver)
   {
-    if (mObservers.RemoveElement(aObserver)) {
-      // Annoyingly, someone could RemoveObserver() an item on the list
-      // while we're in a Broadcast()'s Notify() call.
-      auto i = mBroadcastCopy.IndexOf(aObserver);
-      MOZ_ASSERT(i != NoIndex);
-      mBroadcastCopy[i] = nullptr;
-      return true;
-    }
-    return false;
+    return mObservers.RemoveElement(aObserver);
   }
 
   uint32_t Length()
   {
     return mObservers.Length();
   }
 
-  /**
-   * Call Notify() on each item in the list.
-   * Handles the case of Notify() calling RemoveObserver()
-   */
   void Broadcast(const T& aParam)
   {
-    MOZ_ASSERT(mBroadcastCopy.Empty());
-    mBroadcastCopy = mObservers;
-    uint32_t size = mBroadcastCopy.Length();
+    nsTArray<Observer<T>*> observersCopy(mObservers);
+    uint32_t size = observersCopy.Length();
     for (uint32_t i = 0; i < size; ++i) {
-      // nulled if Removed during Broadcast
-      if (mBroadcastCopy[i]) {
-        mBroadcastCopy[i]->Notify(aParam);
-      }
+      observersCopy[i]->Notify(aParam);
     }
-    mBroadcastCopy.Clear();
   }
 
 protected:
   nsTArray<Observer<T>*> mObservers;
-  nsTArray<Observer<T>*> mBroadcastCopy;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_Observer_h