Remove use of deprecatedDeleteAllValues in NPRemoteObjectMap::pluginDestroyed
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 16:58:33 +0000 (16:58 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Apr 2014 16:58:33 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122496

Reviewed by Brent Fulgham.

* Shared/Plugins/NPRemoteObjectMap.cpp:
(WebKit::NPRemoteObjectMap::pluginDestroyed): Use new-style code and write the
deprecatedDeleteAllValues function out using a loop. Might be nice to return here
and use unique_ptr instead some day, but I tried that before and got it wrong, so
lets do that another time.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167431 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp

index 9bcde6d..4030ca4 100644 (file)
@@ -1,5 +1,18 @@
 2014-04-17  Darin Adler  <darin@apple.com>
 
+        Remove use of deprecatedDeleteAllValues in NPRemoteObjectMap::pluginDestroyed
+        https://bugs.webkit.org/show_bug.cgi?id=122496
+
+        Reviewed by Brent Fulgham.
+
+        * Shared/Plugins/NPRemoteObjectMap.cpp:
+        (WebKit::NPRemoteObjectMap::pluginDestroyed): Use new-style code and write the
+        deprecatedDeleteAllValues function out using a loop. Might be nice to return here
+        and use unique_ptr instead some day, but I tried that before and got it wrong, so
+        lets do that another time.
+
+2014-04-17  Darin Adler  <darin@apple.com>
+
         Add separate flag for IndexedDatabase in workers since the current implementation is not threadsafe
         https://bugs.webkit.org/show_bug.cgi?id=131785
         rdar://problem/16003108
index 8138c2f..9711023 100644 (file)
@@ -196,34 +196,25 @@ NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVar
 
 void NPRemoteObjectMap::pluginDestroyed(Plugin* plugin)
 {
-    Vector<NPObjectMessageReceiver*> messageReceivers;
-
-    // Gather the receivers associated with this plug-in.
-    for (HashMap<uint64_t, NPObjectMessageReceiver*>::const_iterator it = m_registeredNPObjects.begin(), end = m_registeredNPObjects.end(); it != end; ++it) {
-        NPObjectMessageReceiver* npObjectMessageReceiver = it->value;
-        if (npObjectMessageReceiver->plugin() == plugin)
-            messageReceivers.append(npObjectMessageReceiver);
-    }
-
-    // Now delete all the receivers.
-    deprecatedDeleteAllValues(messageReceivers);
-
-    Vector<NPObjectProxy*> objectProxies;
-    for (HashSet<NPObjectProxy*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) {
-        NPObjectProxy* npObjectProxy = *it;
-
-        if (npObjectProxy->plugin() == plugin)
-            objectProxies.append(npObjectProxy);
+    // Gather and delete the receivers associated with this plug-in.
+    Vector<NPObjectMessageReceiver*> receivers;
+    for (auto* receiver : m_registeredNPObjects.values()) {
+        if (receiver->plugin() == plugin)
+            receivers.append(receiver);
     }
+    for (auto* receiver : receivers)
+        delete receiver;
 
     // Invalidate and remove all proxies associated with this plug-in.
-    for (size_t i = 0; i < objectProxies.size(); ++i) {
-        NPObjectProxy* npObjectProxy = objectProxies[i];
-
-        npObjectProxy->invalidate();
-
-        ASSERT(m_npObjectProxies.contains(npObjectProxy));
-        m_npObjectProxies.remove(npObjectProxy);
+    Vector<NPObjectProxy*> proxies;
+    for (auto* proxy : m_npObjectProxies) {
+        if (proxy->plugin() == plugin)
+            proxies.append(proxy);
+    }
+    for (auto* proxy : proxies) {
+        proxy->invalidate();
+        ASSERT(m_npObjectProxies.contains(proxy));
+        m_npObjectProxies.remove(proxy);
     }
 }