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 #ifndef NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ | 5 #ifndef NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ |
6 #define NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ | 6 #define NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "net/spdy/spdy_framer.h" | 13 #include "net/spdy/spdy_framer.h" |
14 | 14 |
15 template <typename T> struct DefaultSingletonTraits; | 15 template <typename Type> struct DefaultSingletonTraits; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 namespace tools { | 18 namespace tools { |
19 | 19 |
20 namespace test { | 20 namespace test { |
21 class QuicInMemoryCachePeer; | 21 class QuicInMemoryCachePeer; |
22 } // namespace test | 22 } // namespace test |
23 | 23 |
24 class QuicServer; | 24 class QuicServer; |
25 | 25 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Simulate a special behavior at a particular path. | 89 // Simulate a special behavior at a particular path. |
90 void AddSpecialResponse(base::StringPiece host, | 90 void AddSpecialResponse(base::StringPiece host, |
91 base::StringPiece path, | 91 base::StringPiece path, |
92 SpecialResponseType response_type); | 92 SpecialResponseType response_type); |
93 | 93 |
94 // |cache_cirectory| can be generated using `wget -p --save-headers <url>`. | 94 // |cache_cirectory| can be generated using `wget -p --save-headers <url>`. |
95 void InitializeFromDirectory(const std::string& cache_directory); | 95 void InitializeFromDirectory(const std::string& cache_directory); |
96 | 96 |
97 private: | 97 private: |
98 typedef base::hash_map<std::string, Response*> ResponseMap; | 98 typedef base::hash_map<std::string, Response*> ResponseMap; |
| 99 |
99 friend struct DefaultSingletonTraits<QuicInMemoryCache>; | 100 friend struct DefaultSingletonTraits<QuicInMemoryCache>; |
100 friend class test::QuicInMemoryCachePeer; | 101 friend class test::QuicInMemoryCachePeer; |
101 | 102 |
102 QuicInMemoryCache(); | 103 QuicInMemoryCache(); |
103 ~QuicInMemoryCache(); | 104 ~QuicInMemoryCache(); |
104 | 105 |
105 void ResetForTests(); | 106 void ResetForTests(); |
106 | 107 |
107 void AddResponseImpl(base::StringPiece host, | 108 void AddResponseImpl(base::StringPiece host, |
108 base::StringPiece path, | 109 base::StringPiece path, |
109 SpecialResponseType response_type, | 110 SpecialResponseType response_type, |
110 const SpdyHeaderBlock& response_headers, | 111 const SpdyHeaderBlock& response_headers, |
111 base::StringPiece response_body); | 112 base::StringPiece response_body); |
112 | 113 |
113 std::string GetKey(base::StringPiece host, base::StringPiece path) const; | 114 std::string GetKey(base::StringPiece host, base::StringPiece path) const; |
114 | 115 |
115 // Cached responses. | 116 // Cached responses. |
116 ResponseMap responses_; | 117 ResponseMap responses_; |
117 | 118 |
118 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache); | 119 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache); |
119 }; | 120 }; |
120 | 121 |
121 } // namespace tools | 122 } // namespace tools |
122 } // namespace net | 123 } // namespace net |
123 | 124 |
124 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ | 125 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ |
OLD | NEW |