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

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

Issue 18655004: Add a quic_in_memory_cache_test data file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "Fix unittest error." Created 7 years, 5 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
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 #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/tools/flip_server/balsa_frame.h" 13 #include "net/tools/flip_server/balsa_frame.h"
14 #include "net/tools/flip_server/balsa_headers.h" 14 #include "net/tools/flip_server/balsa_headers.h"
15 15
16 template <typename T> struct DefaultSingletonTraits; 16 template <typename T> struct DefaultSingletonTraits;
17 17
18 namespace net { 18 namespace net {
19 namespace tools { 19 namespace tools {
20 20
21 extern std::string FLAGS_quic_in_memory_cache_dir; 21 extern std::string FLAGS_quic_in_memory_cache_dir;
22 22
23 class QuicServer; 23 class QuicServer;
24 24
25 namespace test {
26 class QuicInMemoryCacheTest;
27 }
28
25 // In-memory cache for HTTP responses. 29 // In-memory cache for HTTP responses.
26 // Reads from disk cache generated by: 30 // Reads from disk cache generated by:
27 // `wget -p --save_headers <url>` 31 // `wget -p --save_headers <url>`
28 class QuicInMemoryCache { 32 class QuicInMemoryCache {
29 public: 33 public:
30 // Container for response header/body pairs. 34 // Container for response header/body pairs.
31 class Response { 35 class Response {
32 public: 36 public:
33 Response() {} 37 Response() {}
34 ~Response() {} 38 ~Response() {}
(...skipping 24 matching lines...) Expand all
59 const Response* GetResponse(const BalsaHeaders& request_headers) const; 63 const Response* GetResponse(const BalsaHeaders& request_headers) const;
60 64
61 // Add a response to the cache. 65 // Add a response to the cache.
62 void AddResponse(const BalsaHeaders& request_headers, 66 void AddResponse(const BalsaHeaders& request_headers,
63 const BalsaHeaders& response_headers, 67 const BalsaHeaders& response_headers,
64 base::StringPiece response_body); 68 base::StringPiece response_body);
65 69
66 void ResetForTests(); 70 void ResetForTests();
67 71
68 private: 72 private:
73 friend class test::QuicInMemoryCacheTest;
Ryan Hamilton 2013/07/04 14:46:03 If you make ResetForTests call Initialize, then yo
honghaiz 2013/07/04 17:34:04 Done.
69 typedef base::hash_map<std::string, Response*> ResponseMap; 74 typedef base::hash_map<std::string, Response*> ResponseMap;
70 75
71 76
72 QuicInMemoryCache(); 77 QuicInMemoryCache();
73 friend struct DefaultSingletonTraits<QuicInMemoryCache>; 78 friend struct DefaultSingletonTraits<QuicInMemoryCache>;
74 ~QuicInMemoryCache(); 79 ~QuicInMemoryCache();
75 80
81 void Initialize();
76 std::string GetKey(const BalsaHeaders& response_headers) const; 82 std::string GetKey(const BalsaHeaders& response_headers) const;
77 83
78 // Cached responses. 84 // Cached responses.
79 ResponseMap responses_; 85 ResponseMap responses_;
80 86
81 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache); 87 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache);
82 }; 88 };
83 89
84 } // namespace tools 90 } // namespace tools
85 } // namespace net 91 } // namespace net
86 92
87 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ 93 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698