Bug 1413604 P2 Make WorkerHolderToken use an nsTObserverArray to allow for mutation during iteration. r=asuth

This commit is contained in:
Ben Kelly 2017-11-01 16:20:14 -04:00
Родитель ad2679cd26
Коммит 55385cd906
2 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -96,14 +96,17 @@ WorkerHolderToken::Notify(Status aStatus)
return true;
}
mShuttingDown = true;
// Start the asynchronous destruction of our actors. These will call back
// into RemoveActor() once the actor is destroyed.
for (uint32_t i = 0; i < mListenerList.Length(); ++i) {
mListenerList[i]->WorkerShuttingDown();
nsTObserverArray<Listener*>::ForwardIterator iter(mListenerList);
while (iter.HasMore()) {
iter.GetNext()->WorkerShuttingDown();
}
// Set this after calling WorkerShuttingDown() on listener list in case
// one callback triggers another listener to be added.
mShuttingDown = true;
return true;
}

Просмотреть файл

@ -8,7 +8,7 @@
#define mozilla_dom_workers_WorkerHolderToken_h
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "nsTObserverArray.h"
#include "WorkerHolder.h"
BEGIN_WORKERS_NAMESPACE
@ -67,7 +67,7 @@ private:
virtual bool
Notify(workers::Status aStatus) override;
nsTArray<Listener*> mListenerList;
nsTObserverArray<Listener*> mListenerList;
const Status mShutdownStatus;
bool mShuttingDown;