Bug 1397702 - StorageObserver should use nsTObserverArray for the sink in order to support removal when iterating. r=mccr8

This commit is contained in:
Andrea Marchesini 2017-09-10 13:32:13 -04:00
parent f9e2e7cfbc
commit 84764f515b
2 changed files with 5 additions and 4 deletions

View File

@ -140,8 +140,9 @@ StorageObserver::Notify(const char* aTopic,
const nsAString& aOriginAttributesPattern,
const nsACString& aOriginScope)
{
for (uint32_t i = 0; i < mSinks.Length(); ++i) {
StorageObserverSink* sink = mSinks[i];
nsTObserverArray<StorageObserverSink*>::ForwardIterator iter(mSinks);
while (iter.HasMore()) {
StorageObserverSink* sink = iter.GetNext();
sink->Observe(aTopic, aOriginAttributesPattern, aOriginScope);
}
}

View File

@ -10,7 +10,7 @@
#include "nsIObserver.h"
#include "nsITimer.h"
#include "nsWeakReference.h"
#include "nsTArray.h"
#include "nsTObserverArray.h"
#include "nsString.h"
namespace mozilla {
@ -64,7 +64,7 @@ private:
nsCOMPtr<nsIEventTarget> mBackgroundThread;
// Weak references
nsTArray<StorageObserverSink*> mSinks;
nsTObserverArray<StorageObserverSink*> mSinks;
nsCOMPtr<nsITimer> mDBThreadStartDelayTimer;
};