Title: [159123] trunk/Source/WebKit2
Revision
159123
Author
ander...@apple.com
Date
2013-11-12 10:32:53 -0800 (Tue, 12 Nov 2013)

Log Message

Add ImmutableArray::createStringArray
https://bugs.webkit.org/show_bug.cgi?id=124210

Reviewed by Andreas Kling.

Creating an ImmutableArray of WebStrings is a common operation, so add a
helper function to ImmutableArray that does this from a Vector of Strings.

* Shared/ImmutableArray.cpp:
(WebKit::ImmutableArray::createStringArray):
* Shared/ImmutableArray.h:
* Shared/ImmutableDictionary.cpp:
(WebKit::ImmutableDictionary::keys):
* Shared/WebOpenPanelParameters.cpp:
(WebKit::WebOpenPanelParameters::acceptMIMETypes):
(WebKit::WebOpenPanelParameters::selectedFileNames):
* UIProcess/Plugins/WebPluginSiteDataManager.cpp:
(WebKit::WebPluginSiteDataManager::didGetSitesWithData):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
* UIProcess/WebMediaCacheManagerProxy.cpp:
(WebKit::WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache):
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
(WebKit::InjectedBundlePageLoaderClient::featuresUsedInPage):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (159122 => 159123)


--- trunk/Source/WebKit2/ChangeLog	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-12 18:32:53 UTC (rev 159123)
@@ -1,3 +1,30 @@
+2013-11-12  Anders Carlsson  <ander...@apple.com>
+
+        Add ImmutableArray::createStringArray
+        https://bugs.webkit.org/show_bug.cgi?id=124210
+
+        Reviewed by Andreas Kling.
+
+        Creating an ImmutableArray of WebStrings is a common operation, so add a 
+        helper function to ImmutableArray that does this from a Vector of Strings.
+
+        * Shared/ImmutableArray.cpp:
+        (WebKit::ImmutableArray::createStringArray):
+        * Shared/ImmutableArray.h:
+        * Shared/ImmutableDictionary.cpp:
+        (WebKit::ImmutableDictionary::keys):
+        * Shared/WebOpenPanelParameters.cpp:
+        (WebKit::WebOpenPanelParameters::acceptMIMETypes):
+        (WebKit::WebOpenPanelParameters::selectedFileNames):
+        * UIProcess/Plugins/WebPluginSiteDataManager.cpp:
+        (WebKit::WebPluginSiteDataManager::didGetSitesWithData):
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::didGetHostnamesWithCookies):
+        * UIProcess/WebMediaCacheManagerProxy.cpp:
+        (WebKit::WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache):
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+        (WebKit::InjectedBundlePageLoaderClient::featuresUsedInPage):
+
 2013-11-12  Csaba Osztrogonác  <o...@webkit.org>
 
         One more URTBF after r159108.

Modified: trunk/Source/WebKit2/Shared/ImmutableArray.cpp (159122 => 159123)


--- trunk/Source/WebKit2/Shared/ImmutableArray.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/Shared/ImmutableArray.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -26,8 +26,21 @@
 #include "config.h"
 #include "ImmutableArray.h"
 
+#include "WebString.h"
+
 namespace WebKit {
 
+PassRefPtr<ImmutableArray> ImmutableArray::createStringArray(const Vector<String>& strings)
+{
+    Vector<RefPtr<APIObject>> elements;
+    elements.reserveInitialCapacity(strings.size());
+
+    for (const auto& string : strings)
+        elements.uncheckedAppend(WebString::create(string));
+
+    return adopt(elements);
+}
+
 ImmutableArray::ImmutableArray()
 {
 }

Modified: trunk/Source/WebKit2/Shared/ImmutableArray.h (159122 => 159123)


--- trunk/Source/WebKit2/Shared/ImmutableArray.h	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/Shared/ImmutableArray.h	2013-11-12 18:32:53 UTC (rev 159123)
@@ -27,6 +27,7 @@
 #define ImmutableArray_h
 
 #include "APIObject.h"
+#include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
@@ -55,6 +56,8 @@
         return adoptRef(new ImmutableArray(entries));
     }
 
+    static PassRefPtr<ImmutableArray> createStringArray(const Vector<String>&);
+
     virtual ~ImmutableArray();
 
     template<typename T>

Modified: trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp (159122 => 159123)


--- trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -49,15 +49,13 @@
     if (m_map.isEmpty())
         return ImmutableArray::create();
 
-    Vector<RefPtr<APIObject>> vector;
-    vector.reserveInitialCapacity(m_map.size());
+    Vector<RefPtr<APIObject>> keys;
+    keys.reserveInitialCapacity(m_map.size());
 
-    MapType::const_iterator::Keys it = m_map.begin().keys();
-    MapType::const_iterator::Keys end = m_map.end().keys();
-    for (; it != end; ++it)
-        vector.uncheckedAppend(WebString::create(*it));
+    for (const auto& key : m_map.keys())
+        keys.uncheckedAppend(WebString::create(key));
 
-    return ImmutableArray::adopt(vector);
+    return ImmutableArray::adopt(keys);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp (159122 => 159123)


--- trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/Shared/WebOpenPanelParameters.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -51,13 +51,7 @@
 
 PassRefPtr<ImmutableArray> WebOpenPanelParameters::acceptMIMETypes() const
 {
-    Vector<RefPtr<APIObject>> vector;
-    vector.reserveInitialCapacity(m_settings.acceptMIMETypes.size());
-
-    for (const auto& mimeType : m_settings.acceptMIMETypes)
-        vector.uncheckedAppend(WebString::create(mimeType));
-
-    return ImmutableArray::adopt(vector);
+    return ImmutableArray::createStringArray(m_settings.acceptMIMETypes);
 }
 
 #if ENABLE(MEDIA_CAPTURE)
@@ -68,14 +62,8 @@
 #endif
 
 PassRefPtr<ImmutableArray> WebOpenPanelParameters::selectedFileNames() const
-{    
-    Vector<RefPtr<APIObject>> vector;
-    vector.reserveInitialCapacity(m_settings.selectedFiles.size());
-
-    for (const auto& selectedFile : m_settings.selectedFiles)
-        vector.uncheckedAppend(WebString::create(selectedFile));
-
-    return ImmutableArray::adopt(vector);
+{
+    return ImmutableArray::createStringArray(m_settings.selectedFiles);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp (159122 => 159123)


--- trunk/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -165,13 +165,7 @@
         return;
     }
 
-    Vector<RefPtr<APIObject>> sitesArray;
-    sitesArray.reserveInitialCapacity(sites.size());
-
-    for (const auto& site : sites)
-        sitesArray.uncheckedAppend(WebString::create(site));
-
-    callback->performCallbackWithReturnValue(ImmutableArray::adopt(sitesArray).get());
+    callback->performCallbackWithReturnValue(ImmutableArray::createStringArray(sites).get());
 }
 
 void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback> prpCallback)

Modified: trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp (159122 => 159123)


--- trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -115,13 +115,7 @@
         return;
     }
 
-    Vector<RefPtr<APIObject>> hostnameStrings;
-    hostnameStrings.reserveInitialCapacity(hostnames.size());
-
-    for (const auto& hostname : hostnames)
-        hostnameStrings.uncheckedAppend(WebString::create(hostname));
-
-    callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnameStrings).get());
+    callback->performCallbackWithReturnValue(ImmutableArray::createStringArray(hostnames).get());
 }
 
 void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname)

Modified: trunk/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp (159122 => 159123)


--- trunk/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -98,13 +98,7 @@
         return;
     }
 
-    Vector<RefPtr<APIObject>> hostnamesArray;
-    hostnamesArray.reserveInitialCapacity(hostnames.size());
-
-    for (const auto& hostname : hostnames)
-        hostnamesArray.uncheckedAppend(WebString::create(hostname));
-
-    callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnamesArray).get());
+    callback->performCallbackWithReturnValue(ImmutableArray::createStringArray(hostnames).get());
 }
 
 void WebMediaCacheManagerProxy::clearCacheForHostname(const String& hostname)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (159122 => 159123)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2013-11-12 18:22:47 UTC (rev 159122)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2013-11-12 18:32:53 UTC (rev 159123)
@@ -341,13 +341,7 @@
     if (!m_client.featuresUsedInPage)
         return;
 
-    Vector<RefPtr<APIObject>> featureStrings;
-    featureStrings.reserveInitialCapacity(features.size());
-
-    for (const auto& feature : features)
-        featureStrings.uncheckedAppend(WebString::create(feature));
-
-    return m_client.featuresUsedInPage(toAPI(page), toAPI(ImmutableArray::adopt(featureStrings).get()), m_client.clientInfo);
+    return m_client.featuresUsedInPage(toAPI(page), toAPI(ImmutableArray::createStringArray(features).get()), m_client.clientInfo);
 }
 
 void InjectedBundlePageLoaderClient::willDestroyFrame(WebPage* page, WebFrame* frame)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to