[WK2] Add WKProcessPool SPI to efficiently reset all plugin load client policies
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 18:21:58 +0000 (18:21 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 18:21:58 +0000 (18:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173472
<rdar://problem/28858817>

Reviewed by Antti Koivisto.

Follow-up to r218419 to avoid copying the HashMap unnecessarily.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::resetPluginLoadClientPolicies):
* UIProcess/WebProcessPool.h:

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h

index 8e8c7b9..ffad432 100644 (file)
@@ -1,3 +1,17 @@
+2017-06-19  Chris Dumez  <cdumez@apple.com>
+
+        [WK2] Add WKProcessPool SPI to efficiently reset all plugin load client policies
+        https://bugs.webkit.org/show_bug.cgi?id=173472
+        <rdar://problem/28858817>
+
+        Reviewed by Antti Koivisto.
+
+        Follow-up to r218419 to avoid copying the HashMap unnecessarily.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::resetPluginLoadClientPolicies):
+        * UIProcess/WebProcessPool.h:
+
 2017-06-19  Youenn Fablet  <youenn@apple.com>
 
         A cloned MediaStreamTrack should mute independently other tracks using the same source
index d072d74..a213441 100644 (file)
@@ -1595,18 +1595,9 @@ void WebProcessPool::setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy p
     sendToAllProcesses(Messages::WebProcess::SetPluginLoadClientPolicy(policy, host, bundleIdentifier, versionString));
 }
 
-void WebProcessPool::resetPluginLoadClientPolicies(const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& pluginLoadClientPolicies)
+void WebProcessPool::resetPluginLoadClientPolicies(HashMap<String, HashMap<String, HashMap<String, uint8_t>>>&& pluginLoadClientPolicies)
 {
-    m_pluginLoadClientPolicies.clear();
-
-    for (auto& hostPair : pluginLoadClientPolicies) {
-        auto& policiesForHost = m_pluginLoadClientPolicies.ensure(hostPair.key, [] { return HashMap<String, HashMap<String, uint8_t>>(); }).iterator->value;
-        for (auto& bundleIdentifierPair : hostPair.value) {
-            auto& versionsToPolicies = policiesForHost.ensure(bundleIdentifierPair.key, [] { return HashMap<String, uint8_t>(); }).iterator->value;
-            for (auto& versionPair : bundleIdentifierPair.value)
-                versionsToPolicies.set(versionPair.key, versionPair.value);
-        }
-    }
+    m_pluginLoadClientPolicies = WTFMove(pluginLoadClientPolicies);
     sendToAllProcesses(Messages::WebProcess::ResetPluginLoadClientPolicies(m_pluginLoadClientPolicies));
 }
 
index 19a55d4..e611fab 100644 (file)
@@ -197,7 +197,7 @@ public:
     PluginInfoStore& pluginInfoStore() { return m_pluginInfoStore; }
 
     void setPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy, const String& host, const String& bundleIdentifier, const String& versionString);
-    void resetPluginLoadClientPolicies(const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>&);
+    void resetPluginLoadClientPolicies(HashMap<String, HashMap<String, HashMap<String, uint8_t>>>&&);
     void clearPluginClientPolicies();
     const HashMap<String, HashMap<String, HashMap<String, uint8_t>>>& pluginLoadClientPolicies() const { return m_pluginLoadClientPolicies; }
 #endif