summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hal/Hal.cpp3
-rw-r--r--hal/Hal.h1
-rw-r--r--xpcom/glue/Observer.h14
3 files changed, 7 insertions, 11 deletions
diff --git a/hal/Hal.cpp b/hal/Hal.cpp
index e60a3ee61..f88efd6cc 100644
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -21,10 +21,7 @@
#include "nsJSUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Observer.h"
-#include "mozilla/Services.h"
-#include "mozilla/StaticPtr.h"
#include "mozilla/dom/ContentChild.h"
-#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "WindowIdentifier.h"
diff --git a/hal/Hal.h b/hal/Hal.h
index 224b4c451..14247ee2e 100644
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -18,7 +18,6 @@
#include "mozilla/hal_sandbox/PHal.h"
#include "mozilla/HalScreenConfiguration.h"
#include "mozilla/HalTypes.h"
-#include "mozilla/Observer.h"
#include "mozilla/Types.h"
/*
diff --git a/xpcom/glue/Observer.h b/xpcom/glue/Observer.h
index 958e5e4a9..cf9e507dd 100644
--- a/xpcom/glue/Observer.h
+++ b/xpcom/glue/Observer.h
@@ -7,7 +7,7 @@
#ifndef mozilla_Observer_h
#define mozilla_Observer_h
-#include "nsTArray.h"
+#include "nsTObserverArray.h"
namespace mozilla {
@@ -48,7 +48,7 @@ public:
*/
void AddObserver(Observer<T>* aObserver)
{
- mObservers.AppendElement(aObserver);
+ mObservers.AppendElementUnlessExists(aObserver);
}
/**
@@ -67,15 +67,15 @@ public:
void Broadcast(const T& aParam)
{
- nsTArray<Observer<T>*> observersCopy(mObservers);
- uint32_t size = observersCopy.Length();
- for (uint32_t i = 0; i < size; ++i) {
- observersCopy[i]->Notify(aParam);
+ typename nsTObserverArray<Observer<T>*>::ForwardIterator iter(mObservers);
+ while (iter.HasMore()) {
+ Observer<T>* obs = iter.GetNext();
+ obs->Notify(aParam);
}
}
protected:
- nsTArray<Observer<T>*> mObservers;
+ nsTObserverArray<Observer<T>*> mObservers;
};
} // namespace mozilla