| OLD | NEW |
| 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/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
| 13 #include "net/http/http_util.h" | 13 #include "net/http/http_util.h" |
| 14 #include "net/spdy/spdy_http_utils.h" | 14 #include "net/spdy/spdy_http_utils.h" |
| 15 | 15 |
| 16 using base::FilePath; | 16 using base::FilePath; |
| 17 using base::IntToString; | 17 using base::IntToString; |
| 18 using base::StringPiece; | 18 using base::StringPiece; |
| 19 using std::string; | 19 using std::string; |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 namespace tools { | 22 namespace tools { |
| 23 | 23 |
| 24 QuicInMemoryCache::Response::Response() : response_type_(REGULAR_RESPONSE) {} | 24 QuicInMemoryCache::Response::Response() : response_type_(REGULAR_RESPONSE) {} |
| 25 | 25 |
| 26 QuicInMemoryCache::Response::~Response() {} | 26 QuicInMemoryCache::Response::~Response() {} |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 QuicInMemoryCache* QuicInMemoryCache::GetInstance() { | 29 QuicInMemoryCache* QuicInMemoryCache::GetInstance() { |
| 30 return Singleton<QuicInMemoryCache>::get(); | 30 return base::Singleton<QuicInMemoryCache>::get(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( | 33 const QuicInMemoryCache::Response* QuicInMemoryCache::GetResponse( |
| 34 StringPiece host, | 34 StringPiece host, |
| 35 StringPiece path) const { | 35 StringPiece path) const { |
| 36 ResponseMap::const_iterator it = responses_.find(GetKey(host, path)); | 36 ResponseMap::const_iterator it = responses_.find(GetKey(host, path)); |
| 37 if (it == responses_.end()) { | 37 if (it == responses_.end()) { |
| 38 if (default_response_.get()) { | 38 if (default_response_.get()) { |
| 39 return default_response_.get(); | 39 return default_response_.get(); |
| 40 } | 40 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 new_response->set_body(response_body); | 181 new_response->set_body(response_body); |
| 182 responses_[key] = new_response; | 182 responses_[key] = new_response; |
| 183 } | 183 } |
| 184 | 184 |
| 185 string QuicInMemoryCache::GetKey(StringPiece host, StringPiece path) const { | 185 string QuicInMemoryCache::GetKey(StringPiece host, StringPiece path) const { |
| 186 return host.as_string() + path.as_string(); | 186 return host.as_string() + path.as_string(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace tools | 189 } // namespace tools |
| 190 } // namespace net | 190 } // namespace net |
| OLD | NEW |