Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVecto...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2017 22:13:07 +0000 (22:13 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2017 22:13:07 +0000 (22:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178102

Patch by Sam Weinig <sam@webkit.org> on 2017-10-10
Reviewed by Tim Horton.

Source/JavaScriptCore:

* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::clearInspectorBreakpointState):

Source/WebCore:

* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::Watchers::getNotifiersVector const):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::connectionClosedFromServer):
* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::IDBConnectionProxy::connectionToServerLost):
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete):
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::getTracks const):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::windowProxies):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::item const):
* dom/Document.cpp:
(WebCore::Document::prepareForDestruction):
* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::removeMarkers):
* inspector/InspectorWorkerAgent.cpp:
(WebCore::InspectorWorkerAgent::disconnectFromAllWorkerInspectorProxies):
* inspector/NetworkResourcesData.cpp:
* loader/DocumentLoader.cpp:
(WebCore::cancelAll):
(WebCore::setAllDefersLoading):
(WebCore::areAllLoadersPageCacheAcceptable):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::forEachSessionResource):
* loader/mac/DocumentLoaderMac.cpp:
(WebCore::scheduleAll):
(WebCore::unscheduleAll):
* page/ResourceUsageThread.cpp:
(WebCore::ResourceUsageThread::notifyObservers):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::tracks const):

    Replace copyKeysToVector / copyValuesToVector with copyToVector(map.keys()) / copyToVector(map.values())

Source/WebDriver:

* SessionHost.cpp:
(WebDriver::SessionHost::inspectorDisconnected):

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didClose):
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::dumpChangedLayers):
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkitWebContextInvalidateCustomProtocolRequests):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseContainerForall):
* UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
(-[WKWebViewContentProviderRegistry _mimeTypesWithCustomContentProviders]):
* UIProcess/GenericCallback.h:
(WebKit::invalidateCallbackMap):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shutDown):
(WebKit::WebProcessProxy::didClose):
(WebKit::WebProcessProxy::didBecomeUnresponsive):
(WebKit::WebProcessProxy::didBecomeResponsive):
(WebKit::WebProcessProxy::willChangeIsResponsive):
(WebKit::WebProcessProxy::didChangeIsResponsive):
(WebKit::WebProcessProxy::disconnectFramesFromPage):
(WebKit::WebProcessProxy::frameCountInPage const):
(WebKit::WebProcessProxy::requestTermination):
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::invalidate):
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::stopAllStreams):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::cancelAllStreams):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::buildTransaction):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didClose):

Source/WebKitLegacy:

* WebCoreSupport/WebResourceLoadScheduler.cpp:
(WebResourceLoadScheduler::servePendingRequests):

Source/WebKitLegacy/mac:

* History/WebHistory.mm:
(-[WebHistoryPrivate rebuildHistoryByDayIfNeeded:]):
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::stopAllStreams):
* WebCoreSupport/WebUserMediaClient.mm:
(WebUserMediaClient::pageDestroyed):

Source/WTF:

* wtf/HashMap.h:
(WTF::copyKeysToVector): Deleted.
(WTF::copyValuesToVector): Deleted.

    Remove copyKeysToVector and copyValuesToVector which are no longer used.

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

42 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/HashMap.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/geolocation/Geolocation.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/mediastream/MediaStream.cpp
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentMarkerController.cpp
Source/WebCore/inspector/InspectorWorkerAgent.cpp
Source/WebCore/inspector/NetworkResourcesData.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/loader/mac/DocumentLoaderMac.cpp
Source/WebCore/page/ResourceUsageThread.cpp
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp
Source/WebDriver/ChangeLog
Source/WebDriver/SessionHost.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
Source/WebKit/UIProcess/GenericCallback.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
Source/WebKit/WebProcess/Plugins/PluginView.cpp
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/WebCoreSupport/WebResourceLoadScheduler.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/History/WebHistory.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebUserMediaClient.mm

index df278e7..e3d9aec 100644 (file)
@@ -1,3 +1,13 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::clearInspectorBreakpointState):
+
 2017-10-10  Michael Saboff  <msaboff@apple.com>
 
         Unreviewed build fix.
index 24e9039..84370b1 100644 (file)
@@ -1071,9 +1071,7 @@ void InspectorDebuggerAgent::breakProgram(DebuggerFrontendDispatcher::Reason bre
 void InspectorDebuggerAgent::clearInspectorBreakpointState()
 {
     ErrorString dummyError;
-    Vector<String> breakpointIdentifiers;
-    copyKeysToVector(m_breakpointIdentifierToDebugServerBreakpointIDs, breakpointIdentifiers);
-    for (const String& identifier : breakpointIdentifiers)
+    for (const String& identifier : copyToVector(m_breakpointIdentifierToDebugServerBreakpointIDs.keys()))
         removeBreakpoint(dummyError, identifier);
 
     m_javaScriptBreakpoints.clear();
index 1e5bed0..f5b4c18 100644 (file)
@@ -1,3 +1,16 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * wtf/HashMap.h:
+        (WTF::copyKeysToVector): Deleted.
+        (WTF::copyValuesToVector): Deleted.
+        
+            Remove copyKeysToVector and copyValuesToVector which are no longer used.
+
 2017-10-09  Youenn Fablet  <youenn@apple.com>
 
         Vector should be able to easily create from a list of movable only items
index d0dd1f0..85fcf50 100644 (file)
@@ -589,32 +589,6 @@ inline void copyToVector(const HashMap<T, U, V, W, X>& collection, Y& vector)
         vector[i] = { (*it).key, (*it).value };
 }
 
-template<typename T, typename U, typename V, typename W, typename X, typename Y>
-inline void copyKeysToVector(const HashMap<T, U, V, W, X>& collection, Y& vector)
-{
-    typedef typename HashMap<T, U, V, W, X>::const_iterator::Keys iterator;
-    
-    vector.resize(collection.size());
-    
-    iterator it = collection.begin().keys();
-    iterator end = collection.end().keys();
-    for (unsigned i = 0; it != end; ++it, ++i)
-        vector[i] = *it;
-}  
-
-template<typename T, typename U, typename V, typename W, typename X, typename Y>
-inline void copyValuesToVector(const HashMap<T, U, V, W, X>& collection, Y& vector)
-{
-    typedef typename HashMap<T, U, V, W, X>::const_iterator::Values iterator;
-    
-    vector.resize(collection.size());
-    
-    iterator it = collection.begin().values();
-    iterator end = collection.end().values();
-    for (unsigned i = 0; it != end; ++it, ++i)
-        vector[i] = *it;
-}   
-
 } // namespace WTF
 
 using WTF::HashMap;
index 32f243e..37170f6 100644 (file)
@@ -1,3 +1,47 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * Modules/geolocation/Geolocation.cpp:
+        (WebCore::Geolocation::Watchers::getNotifiersVector const):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::connectionClosedFromServer):
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::IDBConnectionProxy::connectionToServerLost):
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete):
+        * Modules/mediastream/MediaStream.cpp:
+        (WebCore::MediaStream::getTracks const):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::windowProxies):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::item const):
+        * dom/Document.cpp:
+        (WebCore::Document::prepareForDestruction):
+        * dom/DocumentMarkerController.cpp:
+        (WebCore::DocumentMarkerController::removeMarkers):
+        * inspector/InspectorWorkerAgent.cpp:
+        (WebCore::InspectorWorkerAgent::disconnectFromAllWorkerInspectorProxies):
+        * inspector/NetworkResourcesData.cpp:
+        * loader/DocumentLoader.cpp:
+        (WebCore::cancelAll):
+        (WebCore::setAllDefersLoading):
+        (WebCore::areAllLoadersPageCacheAcceptable):
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::forEachSessionResource):
+        * loader/mac/DocumentLoaderMac.cpp:
+        (WebCore::scheduleAll):
+        (WebCore::unscheduleAll):
+        * page/ResourceUsageThread.cpp:
+        (WebCore::ResourceUsageThread::notifyObservers):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::tracks const):
+
+            Replace copyKeysToVector / copyValuesToVector with copyToVector(map.keys()) / copyToVector(map.values())
+
 2017-10-10  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
 
         Fix MSVC build with ENCRYPTED_MEDIA enabled
index 0ecdf94..ddce1c4 100644 (file)
@@ -127,7 +127,7 @@ bool Geolocation::Watchers::isEmpty() const
 
 void Geolocation::Watchers::getNotifiersVector(GeoNotifierVector& copy) const
 {
-    copyValuesToVector(m_idToNotifierMap, copy);
+    copy = copyToVector(m_idToNotifierMap.values());
 }
 
 Ref<Geolocation> Geolocation::create(ScriptExecutionContext* context)
index b126da4..26d2e94 100644 (file)
@@ -1368,9 +1368,7 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error)
 
     abortInProgressOperations(error);
 
-    Vector<RefPtr<IDBClient::TransactionOperation>> operations;
-    copyValuesToVector(m_transactionOperationMap, operations);
-
+    auto operations = copyToVector(m_transactionOperationMap.values());
     for (auto& operation : operations) {
         m_currentlyCompletingRequest = nullptr;
         m_transactionOperationsInProgressQueue.append(operation.get());
index fe44ed4..9eb3f25 100644 (file)
@@ -422,7 +422,7 @@ void IDBConnectionProxy::connectionToServerLost(const IDBError& error)
     Vector<uint64_t> databaseConnectionIdentifiers;
     {
         Locker<Lock> locker(m_databaseConnectionMapLock);
-        copyKeysToVector(m_databaseConnectionMap, databaseConnectionIdentifiers);
+        databaseConnectionIdentifiers = copyToVector(m_databaseConnectionMap.keys());
     }
 
     for (auto connectionIdentifier : databaseConnectionIdentifiers) {
@@ -441,7 +441,7 @@ void IDBConnectionProxy::connectionToServerLost(const IDBError& error)
     Vector<IDBResourceIdentifier> openDBRequestIdentifiers;
     {
         Locker<Lock> locker(m_openDBRequestMapLock);
-        copyKeysToVector(m_openDBRequestMap, openDBRequestIdentifiers);
+        openDBRequestIdentifiers = copyToVector(m_openDBRequestMap.keys());
     }
 
     for (auto& requestIdentifier : openDBRequestIdentifiers) {
index e86a232..c332fc1 100644 (file)
@@ -1813,9 +1813,7 @@ void UniqueIDBDatabase::immediateCloseForUserDelete()
     ASSERT(isMainThread());
 
     // Error out all transactions
-    Vector<IDBResourceIdentifier> inProgressIdentifiers;
-    copyKeysToVector(m_inProgressTransactions, inProgressIdentifiers);
-    for (auto& identifier : inProgressIdentifiers)
+    for (auto& identifier : copyToVector(m_inProgressTransactions.keys()))
         m_inProgressTransactions.get(identifier)->abortWithoutCallback();
 
     ASSERT(m_inProgressTransactions.isEmpty());
@@ -1825,28 +1823,20 @@ void UniqueIDBDatabase::immediateCloseForUserDelete()
     m_objectStoreWriteTransactions.clear();
 
     // Error out all pending callbacks
-    Vector<uint64_t> callbackIdentifiers;
     IDBError error = IDBError::userDeleteError();
     IDBKeyData keyData;
     IDBGetResult getResult;
 
-    copyKeysToVector(m_errorCallbacks, callbackIdentifiers);
-    for (auto identifier : callbackIdentifiers)
+    for (auto identifier : copyToVector(m_errorCallbacks.keys()))
         performErrorCallback(identifier, error);
 
-    callbackIdentifiers.clear();
-    copyKeysToVector(m_keyDataCallbacks, callbackIdentifiers);
-    for (auto identifier : callbackIdentifiers)
+    for (auto identifier : copyToVector(m_keyDataCallbacks.keys()))
         performKeyDataCallback(identifier, error, keyData);
 
-    callbackIdentifiers.clear();
-    copyKeysToVector(m_getResultCallbacks, callbackIdentifiers);
-    for (auto identifier : callbackIdentifiers)
+    for (auto identifier : copyToVector(m_getResultCallbacks.keys()))
         performGetResultCallback(identifier, error, getResult);
 
-    callbackIdentifiers.clear();
-    copyKeysToVector(m_countCallbacks, callbackIdentifiers);
-    for (auto identifier : callbackIdentifiers)
+    for (auto identifier : copyToVector(m_countCallbacks.keys()))
         performCountCallback(identifier, error, 0);
 
     // Error out all IDBOpenDBRequests
@@ -1861,7 +1851,7 @@ void UniqueIDBDatabase::immediateCloseForUserDelete()
     m_pendingOpenDBRequests.clear();
 
     // Close all open connections
-    ListHashSet<RefPtr<UniqueIDBDatabaseConnection>> openDatabaseConnections = m_openDatabaseConnections;
+    auto openDatabaseConnections = m_openDatabaseConnections;
     for (auto& connection : openDatabaseConnections)
         connectionClosedFromServer(*connection);
 
index 743ecdb..e5a06c5 100644 (file)
@@ -177,11 +177,7 @@ MediaStreamTrackVector MediaStream::getVideoTracks() const
 
 MediaStreamTrackVector MediaStream::getTracks() const
 {
-    MediaStreamTrackVector tracks;
-    tracks.reserveCapacity(m_trackSet.size());
-    copyValuesToVector(m_trackSet, tracks);
-
-    return tracks;
+    return copyToVector(m_trackSet.values());
 }
 
 void MediaStream::trackDidEnd()
index a077a13..282683c 100644 (file)
@@ -281,9 +281,7 @@ Ref<DOMWrapperWorld> ScriptController::createWorld()
 
 Vector<JSC::Strong<JSDOMWindowProxy>> ScriptController::windowProxies()
 {
-    Vector<JSC::Strong<JSDOMWindowProxy>> windowProxies;
-    copyValuesToVector(m_windowProxies, windowProxies);
-    return windowProxies;
+    return copyToVector(m_windowProxies.values());
 }
 
 void ScriptController::getAllWorlds(Vector<Ref<DOMWrapperWorld>>& worlds)
index 4c8706d..b173b8c 100644 (file)
@@ -4095,9 +4095,8 @@ String CSSComputedStyleDeclaration::item(unsigned i) const
     const auto& customProperties = style->customProperties();
     if (index >= customProperties.size())
         return String();
-    
-    Vector<String, 4> results;
-    copyKeysToVector(customProperties, results);
+
+    auto results = copyToVector(customProperties.keys());
     return results.at(index);
 }
 
index 0e9b7fb..35399f6 100644 (file)
@@ -2338,9 +2338,7 @@ void Document::prepareForDestruction()
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     if (!m_clientToIDMap.isEmpty() && page()) {
-        Vector<WebCore::MediaPlaybackTargetClient*> clients;
-        copyKeysToVector(m_clientToIDMap, clients);
-        for (auto* client : clients)
+        for (auto* client : copyToVector(m_clientToIDMap.keys()))
             removePlaybackTargetPickerClient(*client);
     }
 #endif
index 4d67633..a37e4d1 100644 (file)
@@ -572,7 +572,7 @@ void DocumentMarkerController::removeMarkers(Node* node, OptionSet<DocumentMarke
         return;
     ASSERT(!m_markers.isEmpty());
     
-    MarkerMap::iterator iterator = m_markers.find(node);
+    auto iterator = m_markers.find(node);
     if (iterator != m_markers.end())
         removeMarkersFromList(iterator, markerTypes);
 }
@@ -583,9 +583,7 @@ void DocumentMarkerController::removeMarkers(OptionSet<DocumentMarker::MarkerTyp
         return;
     ASSERT(!m_markers.isEmpty());
 
-    Vector<RefPtr<Node>> nodesWithMarkers;
-    copyKeysToVector(m_markers, nodesWithMarkers);
-    for (auto& node : nodesWithMarkers) {
+    for (auto& node : copyToVector(m_markers.keys())) {
         auto iterator = m_markers.find(node);
         if (iterator != m_markers.end())
             removeMarkersFromList(iterator, markerTypes);
index 13222c7..ddeb7cb 100644 (file)
@@ -145,9 +145,7 @@ void InspectorWorkerAgent::connectToAllWorkerInspectorProxiesForPage()
 
 void InspectorWorkerAgent::disconnectFromAllWorkerInspectorProxies()
 {
-    Vector<WorkerInspectorProxy*> proxies;
-    copyValuesToVector(m_connectedProxies, proxies);
-    for (auto* proxy : proxies)
+    for (auto* proxy : copyToVector(m_connectedProxies.values()))
         proxy->disconnectFromWorkerInspectorController();
 
     m_connectedProxies.clear();
index c17d8e1..afbcc78 100644 (file)
@@ -262,9 +262,7 @@ void NetworkResourcesData::clear(const String& preservedLoaderId)
 
 Vector<NetworkResourcesData::ResourceData*> NetworkResourcesData::resources()
 {
-    Vector<NetworkResourcesData::ResourceData*> resources;
-    copyValuesToVector(m_requestIdToResourceDataMap, resources);
-    return resources;
+    return copyToVector(m_requestIdToResourceDataMap.values());
 }
 
 NetworkResourcesData::ResourceData* NetworkResourcesData::resourceDataForRequestId(const String& requestId)
index 576982e..8c45597 100644 (file)
@@ -100,25 +100,19 @@ namespace WebCore {
 
 static void cancelAll(const ResourceLoaderMap& loaders)
 {
-    Vector<RefPtr<ResourceLoader>> loadersCopy;
-    copyValuesToVector(loaders, loadersCopy);
-    for (auto& loader : loadersCopy)
+    for (auto& loader : copyToVector(loaders.values()))
         loader->cancel();
 }
 
 static void setAllDefersLoading(const ResourceLoaderMap& loaders, bool defers)
 {
-    Vector<RefPtr<ResourceLoader>> loadersCopy;
-    copyValuesToVector(loaders, loadersCopy);
-    for (auto& loader : loadersCopy)
+    for (auto& loader : copyToVector(loaders.values()))
         loader->setDefersLoading(defers);
 }
 
 static bool areAllLoadersPageCacheAcceptable(const ResourceLoaderMap& loaders)
 {
-    Vector<RefPtr<ResourceLoader>> loadersCopy;
-    copyValuesToVector(loaders, loadersCopy);
-    for (auto& loader : loadersCopy) {
+    for (auto& loader : copyToVector(loaders.values())) {
         if (!loader->frameLoader() || !loader->frameLoader()->frame().page())
             return false;
 
index 2a09b60..50919bb 100644 (file)
@@ -278,10 +278,7 @@ void MemoryCache::forEachSessionResource(PAL::SessionID sessionID, const WTF::Fu
     if (it == m_sessionResources.end())
         return;
 
-    Vector<CachedResourceHandle<CachedResource>> resourcesForSession;
-    copyValuesToVector(*it->value, resourcesForSession);
-
-    for (auto& resource : resourcesForSession)
+    for (auto& resource : copyToVector(it->value->values()))
         function(*resource);
 }
 
index 6943a2c..ecda2e0 100644 (file)
@@ -37,17 +37,13 @@ namespace WebCore {
 
 static void scheduleAll(const ResourceLoaderMap& loaders, SchedulePair& pair)
 {
-    Vector<RefPtr<ResourceLoader>> loadersCopy;
-    copyValuesToVector(loaders, loadersCopy);
-    for (auto& loader : loadersCopy)
+    for (auto& loader : copyToVector(loaders.values()))
         loader->schedule(pair);
 }
 
 static void unscheduleAll(const ResourceLoaderMap& loaders, SchedulePair& pair)
 {
-    Vector<RefPtr<ResourceLoader>> loadersCopy;
-    copyValuesToVector(loaders, loadersCopy);
-    for (auto& loader : loadersCopy)
+    for (auto& loader : copyToVector(loaders.values()))
         loader->unschedule(pair);
 }
 
index bb694bd..388f4a4 100644 (file)
@@ -86,7 +86,7 @@ void ResourceUsageThread::notifyObservers(ResourceUsageData&& data)
         {
             auto& resourceUsageThread = ResourceUsageThread::singleton();
             LockHolder locker(resourceUsageThread.m_lock);
-            copyValuesToVector(resourceUsageThread.m_observers, functions);
+            functions = copyToVector(resourceUsageThread.m_observers.values());
         }
 
         for (auto& function : functions)
index 7119dbc..4264770 100644 (file)
@@ -91,11 +91,7 @@ void MediaStreamPrivate::removeObserver(MediaStreamPrivate::Observer& observer)
 
 MediaStreamTrackPrivateVector MediaStreamPrivate::tracks() const
 {
-    MediaStreamTrackPrivateVector tracks;
-    tracks.reserveCapacity(m_trackSet.size());
-    copyValuesToVector(m_trackSet, tracks);
-
-    return tracks;
+    return copyToVector(m_trackSet.values());
 }
 
 void MediaStreamPrivate::updateActiveState(NotifyClientOption notifyClientOption)
index 5b71fa8..63beffb 100644 (file)
@@ -1,3 +1,13 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * SessionHost.cpp:
+        (WebDriver::SessionHost::inspectorDisconnected):
+
 2017-10-02  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         WebDriver: HTTP status code is not correct for some of the errors
index d3fbc1a..d5db6e3 100644 (file)
@@ -36,9 +36,7 @@ namespace WebDriver {
 void SessionHost::inspectorDisconnected()
 {
     // Browser closed or crashed, finish all pending commands with error.
-    Vector<long> messages;
-    copyKeysToVector(m_commandRequests, messages);
-    for (auto messageID : messages) {
+    for (auto messageID : copyToVector(m_commandRequests.keys())) {
         auto responseHandler = m_commandRequests.take(messageID);
         responseHandler({ nullptr, true });
     }
index 69a7b64..8d79fbd 100644 (file)
@@ -1,3 +1,43 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::didClose):
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::dumpChangedLayers):
+        * UIProcess/API/glib/WebKitWebContext.cpp:
+        (webkitWebContextInvalidateCustomProtocolRequests):
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseContainerForall):
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+        (-[WKWebViewContentProviderRegistry _mimeTypesWithCustomContentProviders]):
+        * UIProcess/GenericCallback.h:
+        (WebKit::invalidateCallbackMap):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::shutDown):
+        (WebKit::WebProcessProxy::didClose):
+        (WebKit::WebProcessProxy::didBecomeUnresponsive):
+        (WebKit::WebProcessProxy::didBecomeResponsive):
+        (WebKit::WebProcessProxy::willChangeIsResponsive):
+        (WebKit::WebProcessProxy::didChangeIsResponsive):
+        (WebKit::WebProcessProxy::disconnectFramesFromPage):
+        (WebKit::WebProcessProxy::frameCountInPage const):
+        (WebKit::WebProcessProxy::requestTermination):
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::invalidate):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::stopAllStreams):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::cancelAllStreams):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::buildTransaction):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::didClose):
+
 2017-10-10  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE] Header cairo.h is used in GLib API headers but cannot be found
index 94819a8..1bf5ff0 100644 (file)
@@ -168,9 +168,7 @@ void NetworkConnectionToWebProcess::didClose(IPC::Connection&)
     // Protect ourself as we might be otherwise be deleted during this function.
     Ref<NetworkConnectionToWebProcess> protector(*this);
 
-    Vector<RefPtr<NetworkResourceLoader>> loaders;
-    copyValuesToVector(m_networkResourceLoaders, loaders);
-    for (auto& loader : loaders)
+    for (auto& loader : copyToVector(m_networkResourceLoaders.values()))
         loader->abort();
     ASSERT(m_networkResourceLoaders.isEmpty());
 
index 151c7ad..6c92f00 100644 (file)
@@ -744,8 +744,7 @@ static void dumpChangedLayers(TextStream& ts, const RemoteLayerTreeTransaction::
     ts << "changed-layers";
 
     // Dump the layer properties sorted by layer ID.
-    Vector<GraphicsLayer::PlatformLayerID> layerIDs;
-    copyKeysToVector(changedLayerProperties, layerIDs);
+    auto layerIDs = copyToVector(changedLayerProperties.keys());
     std::sort(layerIDs.begin(), layerIDs.end());
 
     for (auto& layerID : layerIDs) {
index f154d37..4260eab 100644 (file)
@@ -1618,9 +1618,7 @@ void webkitWebContextStopLoadingCustomProtocol(WebKitWebContext* context, uint64
 
 void webkitWebContextInvalidateCustomProtocolRequests(WebKitWebContext* context, LegacyCustomProtocolManagerProxy& manager)
 {
-    Vector<GRefPtr<WebKitURISchemeRequest>> requests;
-    copyValuesToVector(context->priv->uriSchemeRequests, requests);
-    for (auto& request : requests) {
+    for (auto& request : copyToVector(context->priv->uriSchemeRequests.values())) {
         if (webkitURISchemeRequestGetManager(request.get()) == &manager)
             webkitURISchemeRequestInvalidate(request.get());
     }
index dfa0e54..432dac3 100644 (file)
@@ -475,9 +475,7 @@ static void webkitWebViewBaseContainerForall(GtkContainer* container, gboolean i
     WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(container);
     WebKitWebViewBasePrivate* priv = webView->priv;
 
-    Vector<GtkWidget*> children;
-    copyKeysToVector(priv->children, children);
-    for (const auto& child : children) {
+    for (const auto& child : copyToVector(priv->children.keys())) {
         if (priv->children.contains(child))
             (*callback)(child, callbackData);
     }
index 1489781..fbc5c65 100644 (file)
@@ -89,9 +89,7 @@ using namespace WebKit;
 
 - (Vector<String>)_mimeTypesWithCustomContentProviders
 {
-    Vector<String> mimeTypes;
-    copyKeysToVector(_contentProviderForMIMEType, mimeTypes);
-    return mimeTypes;
+    return copyToVector(_contentProviderForMIMEType.keys());
 }
 
 @end
index ebb6d92..2b7b2f5 100644 (file)
@@ -163,9 +163,7 @@ typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
 template<typename T>
 void invalidateCallbackMap(HashMap<uint64_t, T>& callbackMap, CallbackBase::Error error)
 {
-    Vector<T> callbacks;
-    copyValuesToVector(callbackMap, callbacks);
-    for (auto& callback : callbacks)
+    for (auto& callback : copyToVector(callbackMap.values()))
         callback->invalidate(error);
 
     callbackMap.clear();
index b61b59a..d71d718 100644 (file)
@@ -181,18 +181,15 @@ void WebProcessProxy::shutDown()
     m_backgroundResponsivenessTimer.invalidate();
     m_tokenForHoldingLockedFiles = nullptr;
 
-    Vector<RefPtr<WebFrameProxy>> frames;
-    copyValuesToVector(m_frameMap, frames);
-
-    for (size_t i = 0, size = frames.size(); i < size; ++i)
-        frames[i]->webProcessWillShutDown();
+    for (auto& frame : copyToVector(m_frameMap.values()))
+        frame->webProcessWillShutDown();
     m_frameMap.clear();
 
-    for (VisitedLinkStore* visitedLinkStore : m_visitedLinkStores)
+    for (auto* visitedLinkStore : m_visitedLinkStores)
         visitedLinkStore->removeProcess(*this);
     m_visitedLinkStores.clear();
 
-    for (WebUserContentControllerProxy* webUserContentControllerProxy : m_webUserContentControllerProxies)
+    for (auto* webUserContentControllerProxy : m_webUserContentControllerProxies)
         webUserContentControllerProxy->removeProcess(*this);
     m_webUserContentControllerProxies.clear();
 
@@ -625,13 +622,12 @@ void WebProcessProxy::didClose(IPC::Connection&)
 
     webConnection()->didClose();
 
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
+    auto pages = copyToVector(m_pageMap.values());
 
     shutDown();
 
-    for (size_t i = 0, size = pages.size(); i < size; ++i)
-        pages[i]->processDidTerminate(ProcessTerminationReason::Crash);
+    for (auto& page : pages)
+        page->processDidTerminate(ProcessTerminationReason::Crash);
 
 }
 
@@ -653,12 +649,9 @@ void WebProcessProxy::didBecomeUnresponsive()
 {
     m_isResponsive = NoOrMaybe::No;
 
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
-
     auto isResponsiveCallbacks = WTFMove(m_isResponsiveCallbacks);
 
-    for (auto& page : pages)
+    for (auto& page : copyToVector(m_pageMap.values()))
         page->processDidBecomeUnresponsive();
 
     bool isWebProcessResponsive = false;
@@ -670,25 +663,19 @@ void WebProcessProxy::didBecomeResponsive()
 {
     m_isResponsive = NoOrMaybe::Maybe;
 
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
-    for (auto& page : pages)
+    for (auto& page : copyToVector(m_pageMap.values()))
         page->processDidBecomeResponsive();
 }
 
 void WebProcessProxy::willChangeIsResponsive()
 {
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
-    for (auto& page : pages)
+    for (auto& page : copyToVector(m_pageMap.values()))
         page->willChangeProcessIsResponsive();
 }
 
 void WebProcessProxy::didChangeIsResponsive()
 {
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
-    for (auto& page : pages)
+    for (auto& page : copyToVector(m_pageMap.values()))
         page->didChangeProcessIsResponsive();
 }
 
@@ -748,19 +735,17 @@ void WebProcessProxy::didDestroyFrame(uint64_t frameID)
 
 void WebProcessProxy::disconnectFramesFromPage(WebPageProxy* page)
 {
-    Vector<RefPtr<WebFrameProxy>> frames;
-    copyValuesToVector(m_frameMap, frames);
-    for (size_t i = 0, size = frames.size(); i < size; ++i) {
-        if (frames[i]->page() == page)
-            frames[i]->webProcessWillShutDown();
+    for (auto& frame : copyToVector(m_frameMap.values())) {
+        if (frame->page() == page)
+            frame->webProcessWillShutDown();
     }
 }
 
 size_t WebProcessProxy::frameCountInPage(WebPageProxy* page) const
 {
     size_t result = 0;
-    for (HashMap<uint64_t, RefPtr<WebFrameProxy>>::const_iterator iter = m_frameMap.begin(); iter != m_frameMap.end(); ++iter) {
-        if (iter->value->page() == page)
+    for (auto& frame : m_frameMap.values()) {
+        if (frame->page() == page)
             ++result;
     }
     return result;
@@ -888,13 +873,12 @@ void WebProcessProxy::requestTermination(ProcessTerminationReason reason)
     if (webConnection())
         webConnection()->didClose();
 
-    Vector<RefPtr<WebPageProxy>> pages;
-    copyValuesToVector(m_pageMap, pages);
+    auto pages = copyToVector(m_pageMap.values());
 
     shutDown();
 
-    for (size_t i = 0, size = pages.size(); i < size; ++i)
-        pages[i]->processDidTerminate(reason);
+    for (auto& page : pages)
+        page->processDidTerminate(reason);
 }
 
 void WebProcessProxy::stopResponsivenessTimer()
index a7db136..1f4d6dc 100644 (file)
@@ -200,12 +200,9 @@ bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String& scriptString
 
 void NPRuntimeObjectMap::invalidate()
 {
-    Vector<NPJSObject*> npJSObjects;
-    copyValuesToVector(m_npJSObjects, npJSObjects);
-
     // Deallocate all the object wrappers so we won't leak any JavaScript objects.
-    for (size_t i = 0; i < npJSObjects.size(); ++i)
-        deallocateNPObject(npJSObjects[i]);
+    for (auto& npJSObject : copyToVector(m_npJSObjects.values()))
+        deallocateNPObject(npJSObject);
     
     // We shouldn't have any NPJSObjects left now.
     ASSERT(m_npJSObjects.isEmpty());
index ba3ff45..80ab2b4 100644 (file)
@@ -568,11 +568,8 @@ NetscapePluginStream* NetscapePlugin::streamFromID(uint64_t streamID)
 
 void NetscapePlugin::stopAllStreams()
 {
-    Vector<RefPtr<NetscapePluginStream>> streams;
-    copyValuesToVector(m_streams, streams);
-
-    for (size_t i = 0; i < streams.size(); ++i)
-        streams[i]->stop(NPRES_USER_BREAK);
+    for (auto& stream : copyToVector(m_streams.values()))
+        stream->stop(NPRES_USER_BREAK);
 }
 
 bool NetscapePlugin::allowPopups() const
index ecd567f..dc6ca72 100644 (file)
@@ -1284,11 +1284,8 @@ void PluginView::removeStream(Stream* stream)
 
 void PluginView::cancelAllStreams()
 {
-    Vector<RefPtr<Stream>> streams;
-    copyValuesToVector(m_streams, streams);
-    
-    for (size_t i = 0; i < streams.size(); ++i)
-        streams[i]->cancel();
+    for (auto& stream : copyToVector(m_streams.values()))
+        stream->cancel();
 
     // Cancelling a stream removes it from the m_streams map, so if we cancel all streams the map should be empty.
     ASSERT(m_streams.isEmpty());
index 90c486b..4fb5bc8 100644 (file)
@@ -126,9 +126,7 @@ void RemoteLayerTreeContext::buildTransaction(RemoteLayerTreeTransaction& transa
     rootLayerRemote.recursiveBuildTransaction(*this, transaction);
     m_currentTransaction = nullptr;
 
-    Vector<RemoteLayerTreeTransaction::LayerCreationProperties> createdLayerProperties;
-    copyValuesToVector(m_createdLayers, createdLayerProperties);
-    transaction.setCreatedLayers(WTFMove(createdLayerProperties));
+    transaction.setCreatedLayers(copyToVector(m_createdLayers.values()));
     transaction.setDestroyedLayerIDs(WTFMove(m_destroyedLayers));
     
     m_createdLayers.clear();
index b7c1366..c88c8f6 100644 (file)
@@ -665,12 +665,8 @@ void WebProcess::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& de
 void WebProcess::didClose(IPC::Connection&)
 {
 #ifndef NDEBUG
-    // Close all the live pages.
-    Vector<RefPtr<WebPage>> pages;
-    copyValuesToVector(m_pageMap, pages);
-    for (auto& page : pages)
+    for (auto& page : copyToVector(m_pageMap.values()))
         page->close();
-    pages.clear();
 
     GCController::singleton().garbageCollectSoon();
     FontCache::singleton().invalidate();
index 082f101..1966d5b 100644 (file)
@@ -1,3 +1,13 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * WebCoreSupport/WebResourceLoadScheduler.cpp:
+        (WebResourceLoadScheduler::servePendingRequests):
+
 2017-10-09  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Link error: cannot open input file 'WebKitLegacyGUID.lib'
index 1a7e1af..c4b5584 100644 (file)
@@ -222,10 +222,7 @@ void WebResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimum
     
     servePendingRequests(m_nonHTTPProtocolHost, minimumPriority);
 
-    Vector<HostInformation*> hostsToServe;
-    copyValuesToVector(m_hosts, hostsToServe);
-
-    for (auto* host : hostsToServe) {
+    for (auto* host : copyToVector(m_hosts.values())) {
         if (host->hasRequests())
             servePendingRequests(host, minimumPriority);
         else
index 398df3d..a01405b 100644 (file)
@@ -1,3 +1,17 @@
+2017-10-10  Sam Weinig  <sam@webkit.org>
+
+        Replace copyKeysToVector/copyValuesToVector with copyToVector(map.keys())/copyToVector(map.values())
+        https://bugs.webkit.org/show_bug.cgi?id=178102
+
+        Reviewed by Tim Horton.
+
+        * History/WebHistory.mm:
+        (-[WebHistoryPrivate rebuildHistoryByDayIfNeeded:]):
+        * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+        (WebKit::NetscapePluginInstanceProxy::stopAllStreams):
+        * WebCoreSupport/WebUserMediaClient.mm:
+        (WebUserMediaClient::pageDestroyed):
+
 2017-10-09  Robin Morisset  <rmorisset@apple.com>
 
         Make the names of the options consistent
index 90d9a07..9cf8a8e 100644 (file)
@@ -366,8 +366,7 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
 {
     // We clear all the values to present a consistent state when sending the notifications.
     // We keep a reference to the entries for rebuilding the history after the notification.
-    Vector <RetainPtr<NSMutableArray>> entryArrays;
-    copyValuesToVector(*_entriesByDate, entryArrays);
+    auto entryArrays = copyToVector(_entriesByDate->values());
     _entriesByDate->clear();
     
     NSMutableDictionary *entriesByURL = _entriesByURL;
index 106a9fe..a2035ef 100644 (file)
@@ -293,10 +293,8 @@ void NetscapePluginInstanceProxy::layerHostingModeChanged(bool hostsLayersInWind
 
 void NetscapePluginInstanceProxy::stopAllStreams()
 {
-    Vector<RefPtr<HostedNetscapePluginStream>> streamsCopy;
-    copyValuesToVector(m_streams, streamsCopy);
-    for (size_t i = 0; i < streamsCopy.size(); i++)
-        streamsCopy[i]->stop();
+    for (auto& stream : copyToVector(m_streams.values()))
+        stream->stop();
 }
 
 void NetscapePluginInstanceProxy::cleanup()
index 019d11e..0c27fb0 100644 (file)
@@ -109,8 +109,7 @@ WebUserMediaClient::~WebUserMediaClient()
 void WebUserMediaClient::pageDestroyed()
 {
     auto& requestsMap = userMediaRequestsMap();
-    Vector<RetainPtr<WebUserMediaPolicyListener>> pendingRequests;
-    copyValuesToVector(requestsMap, pendingRequests);
+    auto pendingRequests = copyToVector(requestsMap.values());
     requestsMap.clear();
 
     for (auto& request : pendingRequests)
@@ -119,8 +118,7 @@ void WebUserMediaClient::pageDestroyed()
     ASSERT(userMediaRequestsMap().isEmpty());
 
     auto& checkMap = userMediaCheckMap();
-    Vector<RetainPtr<WebUserMediaPolicyCheckerListener>> pendingChecks;
-    copyValuesToVector(checkMap, pendingChecks);
+    auto pendingChecks = copyToVector(checkMap.values());
     checkMap.clear();
 
     for (auto& check : pendingChecks)