diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 19c0d92e4582..512db7dba2c9 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -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& 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& 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; 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.