Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: Source/core/fetch/RawResource.cpp

Issue 645513003: Use C++11 range-based loop in core/fetch (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: mike's comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 void RawResource::didAddClient(ResourceClient* c) 51 void RawResource::didAddClient(ResourceClient* c)
52 { 52 {
53 if (!hasClient(c)) 53 if (!hasClient(c))
54 return; 54 return;
55 // The calls to the client can result in events running, potentially causing 55 // The calls to the client can result in events running, potentially causing
56 // this resource to be evicted from the cache and all clients to be removed, 56 // this resource to be evicted from the cache and all clients to be removed,
57 // so a protector is necessary. 57 // so a protector is necessary.
58 ResourcePtr<RawResource> protect(this); 58 ResourcePtr<RawResource> protect(this);
59 RawResourceClient* client = static_cast<RawResourceClient*>(c); 59 RawResourceClient* client = static_cast<RawResourceClient*>(c);
60 size_t redirectCount = redirectChain().size(); 60 for (const auto& redirect : redirectChain()) {
61 for (size_t i = 0; i < redirectCount; i++) {
62 RedirectPair redirect = redirectChain()[i];
63 ResourceRequest request(redirect.m_request); 61 ResourceRequest request(redirect.m_request);
64 client->redirectReceived(this, request, redirect.m_redirectResponse); 62 client->redirectReceived(this, request, redirect.m_redirectResponse);
65 if (!hasClient(c)) 63 if (!hasClient(c))
66 return; 64 return;
67 } 65 }
68 ASSERT(redirectCount == redirectChain().size());
69 66
70 if (!m_response.isNull()) 67 if (!m_response.isNull())
71 client->responseReceived(this, m_response); 68 client->responseReceived(this, m_response);
72 if (!hasClient(c)) 69 if (!hasClient(c))
73 return; 70 return;
74 if (m_data) 71 if (m_data)
75 client->dataReceived(this, m_data->data(), m_data->size()); 72 client->dataReceived(this, m_data->data(), m_data->size());
76 if (!hasClient(c)) 73 if (!hasClient(c))
77 return; 74 return;
78 Resource::didAddClient(client); 75 Resource::didAddClient(client);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (m_resourceRequest.allowStoredCredentials() != newRequest.allowStoredCred entials()) 163 if (m_resourceRequest.allowStoredCredentials() != newRequest.allowStoredCred entials())
167 return false; 164 return false;
168 165
169 // Ensure most headers match the existing headers before continuing. 166 // Ensure most headers match the existing headers before continuing.
170 // Note that the list of ignored headers includes some headers explicitly re lated to caching. 167 // Note that the list of ignored headers includes some headers explicitly re lated to caching.
171 // A more detailed check of caching policy will be performed later, this is simply a list of 168 // A more detailed check of caching policy will be performed later, this is simply a list of
172 // headers that we might permit to be different and still reuse the existing Resource. 169 // headers that we might permit to be different and still reuse the existing Resource.
173 const HTTPHeaderMap& newHeaders = newRequest.httpHeaderFields(); 170 const HTTPHeaderMap& newHeaders = newRequest.httpHeaderFields();
174 const HTTPHeaderMap& oldHeaders = m_resourceRequest.httpHeaderFields(); 171 const HTTPHeaderMap& oldHeaders = m_resourceRequest.httpHeaderFields();
175 172
176 HTTPHeaderMap::const_iterator end = newHeaders.end(); 173 for (const auto& header : newHeaders) {
177 for (HTTPHeaderMap::const_iterator i = newHeaders.begin(); i != end; ++i) { 174 AtomicString headerName = header.key;
178 AtomicString headerName = i->key; 175 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != oldH eaders.get(headerName))
179 if (!shouldIgnoreHeaderForCacheReuse(headerName) && i->value != oldHeade rs.get(headerName))
180 return false; 176 return false;
181 } 177 }
182 178
183 end = oldHeaders.end(); 179 for (const auto& header : oldHeaders) {
184 for (HTTPHeaderMap::const_iterator i = oldHeaders.begin(); i != end; ++i) { 180 AtomicString headerName = header.key;
185 AtomicString headerName = i->key; 181 if (!shouldIgnoreHeaderForCacheReuse(headerName) && header.value != newH eaders.get(headerName))
186 if (!shouldIgnoreHeaderForCacheReuse(headerName) && i->value != newHeade rs.get(headerName))
187 return false; 182 return false;
188 } 183 }
189 184
190 return true; 185 return true;
191 } 186 }
192 187
193 } // namespace blink 188 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698