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

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

Issue 16354006: Fix a bug in quic_in_memory_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quic_clientserver2
Patch Set: Add unittest. Created 7 years, 6 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/net.gyp ('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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 } // namespace 81 } // namespace
82 82
83 QuicInMemoryCache* QuicInMemoryCache::GetInstance() { 83 QuicInMemoryCache* QuicInMemoryCache::GetInstance() {
84 return Singleton<QuicInMemoryCache>::get(); 84 return Singleton<QuicInMemoryCache>::get();
85 } 85 }
86 86
87 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( 87 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse(
88 const BalsaHeaders& request_headers) const { 88 const BalsaHeaders& request_headers) const {
89 ResponseMap::const_iterator it = responses_.find(GetKey(request_headers)); 89 string key = GetKey(request_headers);
90 StringPiece url(key);
91 // Removing the leading https:// or http://.
92 if (StringPieceUtils::StartsWithIgnoreCase(url, "https://")) {
93 url.remove_prefix(8);
94 } else if (StringPieceUtils::StartsWithIgnoreCase(url, "http://")) {
95 url.remove_prefix(7);
96 }
97
98 ResponseMap::const_iterator it = responses_.find(url.as_string());
90 if (it == responses_.end()) { 99 if (it == responses_.end()) {
91 return NULL; 100 return NULL;
92 } 101 }
93 return it->second; 102 return it->second;
94 } 103 }
95 104
96 void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers, 105 void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
97 const BalsaHeaders& response_headers, 106 const BalsaHeaders& response_headers,
98 StringPiece response_body) { 107 StringPiece response_body) {
99 LOG(INFO) << "Adding response for: " << GetKey(request_headers); 108 LOG(INFO) << "Adding response for: " << GetKey(request_headers);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 STLDeleteValues(&responses_); 206 STLDeleteValues(&responses_);
198 } 207 }
199 208
200 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const { 209 string QuicInMemoryCache::GetKey(const BalsaHeaders& request_headers) const {
201 return request_headers.GetHeader("host").as_string() + 210 return request_headers.GetHeader("host").as_string() +
202 request_headers.request_uri().as_string(); 211 request_headers.request_uri().as_string();
203 } 212 }
204 213
205 } // namespace tools 214 } // namespace tools
206 } // namespace net 215 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gyp ('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