Bug 1182979 - Part 1: Use nsTHashtable::Iterator in PluginInstanceChild. r=jimm

This commit is contained in:
Birunthan Mohanathas 2015-07-16 10:55:12 -07:00
parent 4274ebeef0
commit 314776cd4e

View File

@ -3806,39 +3806,6 @@ PluginInstanceChild::PostChildAsyncCall(ChildAsyncCall* aTask)
ProcessChild::message_loop()->PostTask(FROM_HERE, aTask);
}
static PLDHashOperator
InvalidateObject(DeletingObjectEntry* e, void* userArg)
{
NPObject* o = e->GetKey();
if (!e->mDeleted && o->_class && o->_class->invalidate)
o->_class->invalidate(o);
return PL_DHASH_NEXT;
}
static PLDHashOperator
DeleteObject(DeletingObjectEntry* e, void* userArg)
{
NPObject* o = e->GetKey();
if (!e->mDeleted) {
e->mDeleted = true;
#ifdef NS_BUILD_REFCNT_LOGGING
{
int32_t refcnt = o->referenceCount;
while (refcnt) {
--refcnt;
NS_LOG_RELEASE(o, refcnt, "NPObject");
}
}
#endif
PluginModuleChild::DeallocNPObject(o);
}
return PL_DHASH_NEXT;
}
void
PluginInstanceChild::SwapSurfaces()
{
@ -3946,6 +3913,42 @@ PluginInstanceChild::ClearAllSurfaces()
#endif
}
static void
InvalidateObjects(nsTHashtable<DeletingObjectEntry>& aEntries)
{
for (auto iter = aEntries.Iter(); !iter.Done(); iter.Next()) {
DeletingObjectEntry* e = iter.Get();
NPObject* o = e->GetKey();
if (!e->mDeleted && o->_class && o->_class->invalidate) {
o->_class->invalidate(o);
}
}
}
static void
DeleteObjects(nsTHashtable<DeletingObjectEntry>& aEntries)
{
for (auto iter = aEntries.Iter(); !iter.Done(); iter.Next()) {
DeletingObjectEntry* e = iter.Get();
NPObject* o = e->GetKey();
if (!e->mDeleted) {
e->mDeleted = true;
#ifdef NS_BUILD_REFCNT_LOGGING
{
int32_t refcnt = o->referenceCount;
while (refcnt) {
--refcnt;
NS_LOG_RELEASE(o, refcnt, "NPObject");
}
}
#endif
PluginModuleChild::DeallocNPObject(o);
}
}
}
void
PluginInstanceChild::Destroy()
{
@ -4000,8 +4003,8 @@ PluginInstanceChild::Destroy()
mDeletingHash = new nsTHashtable<DeletingObjectEntry>;
PluginScriptableObjectChild::NotifyOfInstanceShutdown(this);
mDeletingHash->EnumerateEntries(InvalidateObject, nullptr);
mDeletingHash->EnumerateEntries(DeleteObject, nullptr);
InvalidateObjects(*mDeletingHash);
DeleteObjects(*mDeletingHash);
// Null out our cached actors as they should have been killed in the
// PluginInstanceDestroyed call above.