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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/balsa/balsa_frame.h" 13 #include "net/tools/balsa/balsa_frame.h"
14 #include "net/tools/balsa/balsa_headers.h" 14 #include "net/tools/balsa/balsa_headers.h"
15 #include "net/tools/balsa/noop_balsa_visitor.h" 15 #include "net/tools/balsa/noop_balsa_visitor.h"
16 16
17 template <typename T> struct DefaultSingletonTraits; 17 template <typename T>
18 struct DefaultSingletonTraits;
18 19
19 namespace net { 20 namespace net {
20 namespace tools { 21 namespace tools {
21 22
22 namespace test { 23 namespace test {
23 class QuicInMemoryCachePeer; 24 class QuicInMemoryCachePeer;
24 } // namespace 25 } // namespace
25 26
26 extern std::string FLAGS_quic_in_memory_cache_dir; 27 extern std::string FLAGS_quic_in_memory_cache_dir;
27 28
28 class QuicServer; 29 class QuicServer;
29 30
30 // In-memory cache for HTTP responses. 31 // In-memory cache for HTTP responses.
31 // Reads from disk cache generated by: 32 // Reads from disk cache generated by:
32 // `wget -p --save_headers <url>` 33 // `wget -p --save_headers <url>`
33 class QuicInMemoryCache { 34 class QuicInMemoryCache {
34 public: 35 public:
35 enum SpecialResponseType { 36 enum SpecialResponseType {
36 REGULAR_RESPONSE, // Send the headers and body like a server should. 37 REGULAR_RESPONSE, // Send the headers and body like a server should.
37 CLOSE_CONNECTION, // Close the connection (sending the close packet). 38 CLOSE_CONNECTION, // Close the connection (sending the close packet).
38 IGNORE_REQUEST, // Do nothing, expect the client to time out. 39 IGNORE_REQUEST, // Do nothing, expect the client to time out.
39 }; 40 };
40 41
41 // Container for response header/body pairs. 42 // Container for response header/body pairs.
42 class Response { 43 class Response {
43 public: 44 public:
44 Response() : response_type_(REGULAR_RESPONSE) {} 45 Response() : response_type_(REGULAR_RESPONSE) {}
45 ~Response() {} 46 ~Response() {}
46 47
47 const SpecialResponseType response_type() const { return response_type_; } 48 const SpecialResponseType response_type() const { return response_type_; }
48 const BalsaHeaders& headers() const { return headers_; } 49 const BalsaHeaders& headers() const { return headers_; }
49 const base::StringPiece body() const { return base::StringPiece(body_); } 50 const base::StringPiece body() const { return base::StringPiece(body_); }
50 51
51 private: 52 private:
52 friend class QuicInMemoryCache; 53 friend class QuicInMemoryCache;
53 54
54 void set_headers(const BalsaHeaders& headers) { 55 void set_headers(const BalsaHeaders& headers) {
55 headers_.CopyFrom(headers); 56 headers_.CopyFrom(headers);
56 } 57 }
57 void set_body(base::StringPiece body) { 58 void set_body(base::StringPiece body) { body.CopyToString(&body_); }
58 body.CopyToString(&body_);
59 }
60 59
61 SpecialResponseType response_type_; 60 SpecialResponseType response_type_;
62 BalsaHeaders headers_; 61 BalsaHeaders headers_;
63 std::string body_; 62 std::string body_;
64 63
65 DISALLOW_COPY_AND_ASSIGN(Response); 64 DISALLOW_COPY_AND_ASSIGN(Response);
66 }; 65 };
67 66
68 // Returns the singleton instance of the cache. 67 // Returns the singleton instance of the cache.
69 static QuicInMemoryCache* GetInstance(); 68 static QuicInMemoryCache* GetInstance();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Cached responses. 109 // Cached responses.
111 ResponseMap responses_; 110 ResponseMap responses_;
112 111
113 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache); 112 DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCache);
114 }; 113 };
115 114
116 } // namespace tools 115 } // namespace tools
117 } // namespace net 116 } // namespace net
118 117
119 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_ 118 #endif // NET_TOOLS_QUIC_QUIC_IN_MEMORY_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698