Bug 893242 - Part 3: Add ContentParent::GetAllEvenIfDead(). r=bent

To do this, we got rid of the explicit removal of a ContentParent from
sContentParents in MarkAsDead().  Instead, we rely on
LinkedListElement's destructor to remove the ContentParent from
sContentParents.

Thus, a ContentParent stays in sContentParents until it's destructed.
ContentParent::GetAll() checks whether the ContentParent is still alive,
so its behavior is unchanged.
This commit is contained in:
Justin Lebar 2013-07-17 14:31:10 -07:00
Родитель 21412f80a2
Коммит 545d682d16
2 изменённых файлов: 18 добавлений и 5 удалений

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

@ -519,6 +519,23 @@ ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
return;
}
for (ContentParent* cp = sContentParents->getFirst(); cp;
cp = cp->getNext()) {
if (cp->mIsAlive) {
aArray.AppendElement(cp);
}
}
}
void
ContentParent::GetAllEvenIfDead(nsTArray<ContentParent*>& aArray)
{
aArray.Clear();
if (!sContentParents) {
return;
}
for (ContentParent* cp = sContentParents->getFirst(); cp;
cp = cp->getNext()) {
aArray.AppendElement(cp);
@ -788,11 +805,6 @@ ContentParent::MarkAsDead()
}
mIsAlive = false;
// Remove from sContentParents.
if (isInList()) {
remove();
}
}
void

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

@ -106,6 +106,7 @@ public:
nsIDOMElement* aFrameElement);
static void GetAll(nsTArray<ContentParent*>& aArray);
static void GetAllEvenIfDead(nsTArray<ContentParent*>& aArray);
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER