Skip to content
Permalink
Browse files
Replace copyKeysToVector/copyValuesToVector with copyToVector(map.key…
…s())/copyToVector(map.values())

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.

Canonical link: https://commits.webkit.org/194392@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Sam Weinig authored and webkit-commit-queue committed Oct 10, 2017
1 parent 4a05828 commit 2824311c4663460c07d1cfd55cb8c517e209c32c
Showing 42 changed files with 209 additions and 192 deletions.
@@ -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.
@@ -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();
@@ -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
@@ -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;
@@ -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
@@ -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)
@@ -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());
@@ -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) {
@@ -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);

@@ -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()
@@ -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)
@@ -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);
}

@@ -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
@@ -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);
@@ -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();
@@ -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)
@@ -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;

@@ -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);
}

@@ -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);
}

@@ -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)
@@ -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)
@@ -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

0 comments on commit 2824311

Please sign in to comment.