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

Side by Side Diff: net/tools/quic/quic_in_memory_cache.cc

Issue 2229393003: net: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_in_memory_cache_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/quic/quic_in_memory_cache.h" 5 #include "net/tools/quic/quic_in_memory_cache.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void QuicInMemoryCache::AddSpecialResponse(StringPiece host, 201 void QuicInMemoryCache::AddSpecialResponse(StringPiece host,
202 StringPiece path, 202 StringPiece path,
203 SpecialResponseType response_type) { 203 SpecialResponseType response_type) {
204 AddResponseImpl(host, path, response_type, SpdyHeaderBlock(), "", 204 AddResponseImpl(host, path, response_type, SpdyHeaderBlock(), "",
205 SpdyHeaderBlock()); 205 SpdyHeaderBlock());
206 } 206 }
207 207
208 QuicInMemoryCache::QuicInMemoryCache() {} 208 QuicInMemoryCache::QuicInMemoryCache() {}
209 209
210 void QuicInMemoryCache::ResetForTests() { 210 void QuicInMemoryCache::ResetForTests() {
211 STLDeleteValues(&responses_); 211 base::STLDeleteValues(&responses_);
212 server_push_resources_.clear(); 212 server_push_resources_.clear();
213 } 213 }
214 214
215 void QuicInMemoryCache::InitializeFromDirectory(const string& cache_directory) { 215 void QuicInMemoryCache::InitializeFromDirectory(const string& cache_directory) {
216 if (cache_directory.empty()) { 216 if (cache_directory.empty()) {
217 QUIC_BUG << "cache_directory must not be empty."; 217 QUIC_BUG << "cache_directory must not be empty.";
218 return; 218 return;
219 } 219 }
220 VLOG(1) << "Attempting to initialize QuicInMemoryCache from directory: " 220 VLOG(1) << "Attempting to initialize QuicInMemoryCache from directory: "
221 << cache_directory; 221 << cache_directory;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 auto resource_range = server_push_resources_.equal_range(request_url); 272 auto resource_range = server_push_resources_.equal_range(request_url);
273 for (auto it = resource_range.first; it != resource_range.second; ++it) { 273 for (auto it = resource_range.first; it != resource_range.second; ++it) {
274 resources.push_back(it->second); 274 resources.push_back(it->second);
275 } 275 }
276 DVLOG(1) << "Found " << resources.size() << " push resources for " 276 DVLOG(1) << "Found " << resources.size() << " push resources for "
277 << request_url; 277 << request_url;
278 return resources; 278 return resources;
279 } 279 }
280 280
281 QuicInMemoryCache::~QuicInMemoryCache() { 281 QuicInMemoryCache::~QuicInMemoryCache() {
282 STLDeleteValues(&responses_); 282 base::STLDeleteValues(&responses_);
283 } 283 }
284 284
285 void QuicInMemoryCache::AddResponseImpl(StringPiece host, 285 void QuicInMemoryCache::AddResponseImpl(StringPiece host,
286 StringPiece path, 286 StringPiece path,
287 SpecialResponseType response_type, 287 SpecialResponseType response_type,
288 SpdyHeaderBlock response_headers, 288 SpdyHeaderBlock response_headers,
289 StringPiece response_body, 289 StringPiece response_body,
290 SpdyHeaderBlock response_trailers) { 290 SpdyHeaderBlock response_trailers) {
291 DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\""; 291 DCHECK(!host.empty()) << "Host must be populated, e.g. \"www.google.com\"";
292 string key = GetKey(host, path); 292 string key = GetKey(host, path);
293 if (ContainsKey(responses_, key)) { 293 if (base::ContainsKey(responses_, key)) {
294 QUIC_BUG << "Response for '" << key << "' already exists!"; 294 QUIC_BUG << "Response for '" << key << "' already exists!";
295 return; 295 return;
296 } 296 }
297 Response* new_response = new Response(); 297 Response* new_response = new Response();
298 new_response->set_response_type(response_type); 298 new_response->set_response_type(response_type);
299 new_response->set_headers(std::move(response_headers)); 299 new_response->set_headers(std::move(response_headers));
300 new_response->set_body(response_body); 300 new_response->set_body(response_body);
301 new_response->set_trailers(std::move(response_trailers)); 301 new_response->set_trailers(std::move(response_trailers));
302 DVLOG(1) << "Add response with key " << key; 302 DVLOG(1) << "Add response with key " << key;
303 responses_[key] = new_response; 303 responses_[key] = new_response;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 for (auto it = resource_range.first; it != resource_range.second; ++it) { 344 for (auto it = resource_range.first; it != resource_range.second; ++it) {
345 ServerPushInfo push_resource = it->second; 345 ServerPushInfo push_resource = it->second;
346 if (push_resource.request_url.spec() == resource.request_url.spec()) { 346 if (push_resource.request_url.spec() == resource.request_url.spec()) {
347 return true; 347 return true;
348 } 348 }
349 } 349 }
350 return false; 350 return false;
351 } 351 }
352 352
353 } // namespace net 353 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_in_memory_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698