OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quic/quic_in_memory_cache.h" | 5 #include "net/quic/quic_in_memory_cache.h" |
6 | 6 |
7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // static | 32 // static |
33 QuicInMemoryCache* QuicInMemoryCache::GetInstance() { | 33 QuicInMemoryCache* QuicInMemoryCache::GetInstance() { |
34 return Singleton<QuicInMemoryCache>::get(); | 34 return Singleton<QuicInMemoryCache>::get(); |
35 } | 35 } |
36 | 36 |
37 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( | 37 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( |
38 const GURL& url) const { | 38 const GURL& url) const { |
39 ResponseMap::const_iterator it = responses_.find(GetKey(url)); | 39 ResponseMap::const_iterator it = responses_.find(GetKey(url)); |
40 if (it == responses_.end()) { | 40 if (it == responses_.end()) { |
41 return NULL; | 41 return nullptr; |
42 } | 42 } |
43 return it->second; | 43 return it->second; |
44 } | 44 } |
45 | 45 |
46 void QuicInMemoryCache::AddSimpleResponse(StringPiece path, | 46 void QuicInMemoryCache::AddSimpleResponse(StringPiece path, |
47 StringPiece version, | 47 StringPiece version, |
48 StringPiece response_code, | 48 StringPiece response_code, |
49 StringPiece response_detail, | 49 StringPiece response_detail, |
50 StringPiece body) { | 50 StringPiece body) { |
51 GURL url("http://" + path.as_string()); | 51 GURL url("http://" + path.as_string()); |
(...skipping 24 matching lines...) Expand all Loading... |
76 Response* new_response = new Response(); | 76 Response* new_response = new Response(); |
77 new_response->set_headers(response_headers); | 77 new_response->set_headers(response_headers); |
78 new_response->set_body(response_body); | 78 new_response->set_body(response_body); |
79 responses_[key] = new_response; | 79 responses_[key] = new_response; |
80 } | 80 } |
81 | 81 |
82 void QuicInMemoryCache::AddSpecialResponse(StringPiece path, | 82 void QuicInMemoryCache::AddSpecialResponse(StringPiece path, |
83 SpecialResponseType response_type) { | 83 SpecialResponseType response_type) { |
84 GURL url("http://" + path.as_string()); | 84 GURL url("http://" + path.as_string()); |
85 | 85 |
86 AddResponse(url, NULL, string()); | 86 AddResponse(url, nullptr, string()); |
87 responses_[GetKey(url)]->response_type_ = response_type; | 87 responses_[GetKey(url)]->response_type_ = response_type; |
88 } | 88 } |
89 | 89 |
90 QuicInMemoryCache::QuicInMemoryCache() { | 90 QuicInMemoryCache::QuicInMemoryCache() { |
91 Initialize(); | 91 Initialize(); |
92 } | 92 } |
93 | 93 |
94 void QuicInMemoryCache::ResetForTests() { | 94 void QuicInMemoryCache::ResetForTests() { |
95 STLDeleteValues(&responses_); | 95 STLDeleteValues(&responses_); |
96 Initialize(); | 96 Initialize(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 QuicInMemoryCache::~QuicInMemoryCache() { | 174 QuicInMemoryCache::~QuicInMemoryCache() { |
175 STLDeleteValues(&responses_); | 175 STLDeleteValues(&responses_); |
176 } | 176 } |
177 | 177 |
178 string QuicInMemoryCache::GetKey(const GURL& url) const { | 178 string QuicInMemoryCache::GetKey(const GURL& url) const { |
179 // Take everything but the scheme portion of the URL. | 179 // Take everything but the scheme portion of the URL. |
180 return url.host() + url.PathForRequest(); | 180 return url.host() + url.PathForRequest(); |
181 } | 181 } |
182 | 182 |
183 } // namespace net | 183 } // namespace net |
OLD | NEW |