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

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

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <unordered_map> 12 #include <unordered_map>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/strings/string_piece.h" 17 #include "base/strings/string_piece.h"
18 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
19 #include "net/quic/core/spdy_utils.h" 19 #include "net/quic/core/spdy_utils.h"
20 #include "net/spdy/spdy_framer.h" 20 #include "net/spdy/spdy_framer.h"
21 #include "url/gurl.h" 21 #include "url/gurl.h"
22 22
23 namespace net { 23 namespace net {
24 24
25 // In-memory cache for HTTP responses. 25 // In-memory cache for HTTP responses.
26 // Reads from disk cache generated by: 26 // Reads from disk cache generated by:
27 // `wget -p --save_headers <url>` 27 // `wget -p --save_headers <url>`
28 class QuicInMemoryCache { 28 class QuicHttpResponseCache {
29 public: 29 public:
30 // A ServerPushInfo contains path of the push request and everything needed in 30 // A ServerPushInfo contains path of the push request and everything needed in
31 // comprising a response for the push request. 31 // comprising a response for the push request.
32 struct ServerPushInfo { 32 struct ServerPushInfo {
33 ServerPushInfo(GURL request_url, 33 ServerPushInfo(GURL request_url,
34 SpdyHeaderBlock headers, 34 SpdyHeaderBlock headers,
35 SpdyPriority priority, 35 SpdyPriority priority,
36 std::string body); 36 std::string body);
37 ServerPushInfo(const ServerPushInfo& other); 37 ServerPushInfo(const ServerPushInfo& other);
38 GURL request_url; 38 GURL request_url;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const std::string file_name_string_; 113 const std::string file_name_string_;
114 std::string file_contents_; 114 std::string file_contents_;
115 base::StringPiece body_; 115 base::StringPiece body_;
116 SpdyHeaderBlock spdy_headers_; 116 SpdyHeaderBlock spdy_headers_;
117 base::StringPiece x_original_url_; 117 base::StringPiece x_original_url_;
118 std::vector<base::StringPiece> push_urls_; 118 std::vector<base::StringPiece> push_urls_;
119 119
120 private: 120 private:
121 base::StringPiece host_; 121 base::StringPiece host_;
122 base::StringPiece path_; 122 base::StringPiece path_;
123 QuicInMemoryCache* cache_; 123 QuicHttpResponseCache* cache_;
124 124
125 DISALLOW_COPY_AND_ASSIGN(ResourceFile); 125 DISALLOW_COPY_AND_ASSIGN(ResourceFile);
126 }; 126 };
127 127
128 QuicInMemoryCache(); 128 QuicHttpResponseCache();
129 ~QuicInMemoryCache(); 129 ~QuicHttpResponseCache();
130 130
131 // Retrieve a response from this cache for a given host and path.. 131 // Retrieve a response from this cache for a given host and path..
132 // If no appropriate response exists, nullptr is returned. 132 // If no appropriate response exists, nullptr is returned.
133 const Response* GetResponse(base::StringPiece host, 133 const Response* GetResponse(base::StringPiece host,
134 base::StringPiece path) const; 134 base::StringPiece path) const;
135 135
136 // Adds a simple response to the cache. The response headers will 136 // Adds a simple response to the cache. The response headers will
137 // only contain the "content-length" header with the length of |body|. 137 // only contain the "content-length" header with the length of |body|.
138 void AddSimpleResponse(base::StringPiece host, 138 void AddSimpleResponse(base::StringPiece host,
139 base::StringPiece path, 139 base::StringPiece path,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // The default response for cache misses, if set. 206 // The default response for cache misses, if set.
207 std::unique_ptr<Response> default_response_; 207 std::unique_ptr<Response> default_response_;
208 208
209 // A map from request URL to associated server push responses (if any). 209 // A map from request URL to associated server push responses (if any).
210 std::multimap<std::string, ServerPushInfo> server_push_resources_; 210 std::multimap<std::string, ServerPushInfo> server_push_resources_;
211 211
212 // Protects against concurrent access from test threads setting responses, and 212 // Protects against concurrent access from test threads setting responses, and
213 // server threads accessing those responses. 213 // server threads accessing those responses.
214 mutable base::Lock response_mutex_; 214 mutable base::Lock response_mutex_;
215 215
216 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache); 216 DISALLOW_COPY_AND_ASSIGN(QuicHttpResponseCache);
217 }; 217 };
218 218
219 } // namespace net 219 } // namespace net
220 220
221 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ 221 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_
OLDNEW
« no previous file with comments | « net/tools/quic/quic_epoll_connection_helper.h ('k') | net/tools/quic/quic_http_response_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698