Chromium Code Reviews| Index: Source/core/fetch/Resource.cpp |
| diff --git a/Source/core/fetch/Resource.cpp b/Source/core/fetch/Resource.cpp |
| index 92c8f3671b2e3d25128c6255c1432327b77cc627..db5f006ad3a775f0eeec7ad854f2a4234735ef82 100644 |
| --- a/Source/core/fetch/Resource.cpp |
| +++ b/Source/core/fetch/Resource.cpp |
| @@ -623,9 +623,7 @@ void Resource::finishPendingClients() |
| Vector<ResourceClient*> clientsToNotify; |
| copyToVector(m_clientsAwaitingCallback, clientsToNotify); |
| - for (size_t i = 0; i < clientsToNotify.size(); ++i) { |
| - ResourceClient* client = clientsToNotify[i]; |
| - |
| + for (const auto& client : clientsToNotify) { |
| // Handle case (2) to skip removed clients. |
| if (!m_clientsAwaitingCallback.remove(client)) |
| continue; |
| @@ -695,9 +693,7 @@ void Resource::switchClientsToRevalidatedResource() |
| m_resourceToRevalidate->m_identifier = m_identifier; |
| m_switchingClientsToRevalidatedResource = true; |
| - HashSet<ResourcePtrBase*>::iterator end = m_handlesToRevalidate.end(); |
| - for (HashSet<ResourcePtrBase*>::iterator it = m_handlesToRevalidate.begin(); it != end; ++it) { |
| - ResourcePtrBase* handle = *it; |
| + for (const auto& handle : m_handlesToRevalidate) { |
| handle->m_resource = m_resourceToRevalidate; |
| m_resourceToRevalidate->registerHandle(handle); |
| --m_handleCount; |
| @@ -706,12 +702,10 @@ void Resource::switchClientsToRevalidatedResource() |
| m_handlesToRevalidate.clear(); |
| Vector<ResourceClient*> clientsToMove; |
| - HashCountedSet<ResourceClient*>::iterator end2 = m_clients.end(); |
| - for (HashCountedSet<ResourceClient*>::iterator it = m_clients.begin(); it != end2; ++it) { |
| - ResourceClient* client = it->key; |
| - unsigned count = it->value; |
| + for (const auto& client : m_clients) { |
|
Mike West
2014/10/17 10:38:49
Nit: How about "clientHash" rather than "client".
riju_
2014/10/17 18:36:48
Done.
|
| + unsigned count = client.value; |
| while (count) { |
| - clientsToMove.append(client); |
| + clientsToMove.append(client.key); |
| --count; |
| } |
| } |
| @@ -741,16 +735,15 @@ void Resource::updateResponseAfterRevalidation(const ResourceResponse& validatin |
| // RFC2616 10.3.5 |
| // Update cached headers from the 304 response |
| const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); |
| - HTTPHeaderMap::const_iterator end = newHeaders.end(); |
| - for (HTTPHeaderMap::const_iterator it = newHeaders.begin(); it != end; ++it) { |
| + for (const auto& header : newHeaders) { |
| // Entity headers should not be sent by servers when generating a 304 |
| // response; misconfigured servers send them anyway. We shouldn't allow |
| // such headers to update the original request. We'll base this on the |
| // list defined by RFC2616 7.1, with a few additions for extension headers |
| // we care about. |
| - if (!shouldUpdateHeaderAfterRevalidation(it->key)) |
| + if (!shouldUpdateHeaderAfterRevalidation(header.key)) |
| continue; |
| - m_response.setHTTPHeaderField(it->key, it->value); |
| + m_response.setHTTPHeaderField(header.key, header.value); |
| } |
| } |
| @@ -812,10 +805,10 @@ void Resource::unregisterHandle(ResourcePtrBase* h) |
| bool Resource::canReuseRedirectChain() |
| { |
| - for (size_t i = 0; i < m_redirectChain.size(); ++i) { |
| - if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTimestamp)) |
| + for (auto& redirect : m_redirectChain) { |
| + if (!canUseResponse(redirect.m_redirectResponse, m_responseTimestamp)) |
| return false; |
| - if (m_redirectChain[i].m_request.cacheControlContainsNoCache() || m_redirectChain[i].m_request.cacheControlContainsNoStore()) |
| + if (redirect.m_request.cacheControlContainsNoCache() || redirect.m_request.cacheControlContainsNoStore()) |
| return false; |
| } |
| return true; |
| @@ -913,20 +906,19 @@ bool Resource::ResourceCallback::isScheduled(Resource* resource) const |
| void Resource::ResourceCallback::timerFired(Timer<ResourceCallback>*) |
| { |
| - HashSet<Resource*>::iterator end = m_resourcesWithPendingClients.end(); |
| - Vector<ResourcePtr<Resource> > resources; |
| - for (HashSet<Resource*>::iterator it = m_resourcesWithPendingClients.begin(); it != end; ++it) |
| - resources.append(*it); |
| + Vector<ResourcePtr<Resource>> resources; |
| + for (const auto& resource : m_resourcesWithPendingClients) |
| + resources.append(resource); |
| m_resourcesWithPendingClients.clear(); |
| - for (size_t i = 0; i < resources.size(); i++) { |
| - resources[i]->assertAlive(); |
| - resources[i]->finishPendingClients(); |
| - resources[i]->assertAlive(); |
| + for (const auto& resource : resources) { |
| + resource->assertAlive(); |
| + resource->finishPendingClients(); |
| + resource->assertAlive(); |
| } |
| - for (size_t i = 0; i < resources.size(); i++) |
| - resources[i]->assertAlive(); |
| + for (const auto resource : resources) |
|
Mike West
2014/10/17 10:38:49
Why did you choose `const auto&` above, and `const
riju_
2014/10/17 18:36:48
my bad. Done.
|
| + resource->assertAlive(); |
| } |
| static const char* initatorTypeNameToString(const AtomicString& initiatorTypeName) |