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_HTTP_HTTP_SERVER_PROPERTIES_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/mru_cache.h" | |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 12 #include "base/time/time.h" |
14 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
15 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
16 #include "net/http/http_pipelined_host_capability.h" | 15 #include "net/http/http_pipelined_host_capability.h" |
17 #include "net/socket/next_proto.h" | 16 #include "net/socket/next_proto.h" |
18 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. | 17 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
19 | 18 |
20 namespace net { | 19 namespace net { |
21 | 20 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 bool Equals(const PortAlternateProtocolPair& other) const { | 55 bool Equals(const PortAlternateProtocolPair& other) const { |
57 return port == other.port && protocol == other.protocol; | 56 return port == other.port && protocol == other.protocol; |
58 } | 57 } |
59 | 58 |
60 std::string ToString() const; | 59 std::string ToString() const; |
61 | 60 |
62 uint16 port; | 61 uint16 port; |
63 AlternateProtocol protocol; | 62 AlternateProtocol protocol; |
64 }; | 63 }; |
65 | 64 |
66 typedef base::MRUCache< | 65 typedef std::map<HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; |
67 HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; | |
68 typedef std::map<HostPortPair, SettingsMap> SpdySettingsMap; | 66 typedef std::map<HostPortPair, SettingsMap> SpdySettingsMap; |
69 typedef std::map<HostPortPair, | 67 typedef std::map<HostPortPair, |
70 HttpPipelinedHostCapability> PipelineCapabilityMap; | 68 HttpPipelinedHostCapability> PipelineCapabilityMap; |
71 | 69 |
72 extern const char kAlternateProtocolHeader[]; | 70 extern const char kAlternateProtocolHeader[]; |
73 | 71 |
74 // The interface for setting/retrieving the HTTP server properties. | 72 // The interface for setting/retrieving the HTTP server properties. |
75 // Currently, this class manages servers': | 73 // Currently, this class manages servers': |
76 // * SPDY support (based on NPN results) | 74 // * SPDY support (based on NPN results) |
77 // * Alternate-Protocol support | 75 // * Alternate-Protocol support |
(...skipping 16 matching lines...) Expand all Loading... |
94 | 92 |
95 // Returns true if |server| supports SPDY. | 93 // Returns true if |server| supports SPDY. |
96 virtual bool SupportsSpdy(const HostPortPair& server) const = 0; | 94 virtual bool SupportsSpdy(const HostPortPair& server) const = 0; |
97 | 95 |
98 // Add |server| into the persistent store. Should only be called from IO | 96 // Add |server| into the persistent store. Should only be called from IO |
99 // thread. | 97 // thread. |
100 virtual void SetSupportsSpdy(const HostPortPair& server, | 98 virtual void SetSupportsSpdy(const HostPortPair& server, |
101 bool support_spdy) = 0; | 99 bool support_spdy) = 0; |
102 | 100 |
103 // Returns true if |server| has an Alternate-Protocol header. | 101 // Returns true if |server| has an Alternate-Protocol header. |
104 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; | 102 virtual bool HasAlternateProtocol(const HostPortPair& server) const = 0; |
105 | 103 |
106 // Returns the Alternate-Protocol and port for |server|. | 104 // Returns the Alternate-Protocol and port for |server|. |
107 // HasAlternateProtocol(server) must be true. | 105 // HasAlternateProtocol(server) must be true. |
108 virtual PortAlternateProtocolPair GetAlternateProtocol( | 106 virtual PortAlternateProtocolPair GetAlternateProtocol( |
109 const HostPortPair& server) = 0; | 107 const HostPortPair& server) const = 0; |
110 | 108 |
111 // Sets the Alternate-Protocol for |server|. | 109 // Sets the Alternate-Protocol for |server|. |
112 virtual void SetAlternateProtocol(const HostPortPair& server, | 110 virtual void SetAlternateProtocol(const HostPortPair& server, |
113 uint16 alternate_port, | 111 uint16 alternate_port, |
114 AlternateProtocol alternate_protocol) = 0; | 112 AlternateProtocol alternate_protocol) = 0; |
115 | 113 |
116 // Sets the Alternate-Protocol for |server| to be BROKEN. | 114 // Sets the Alternate-Protocol for |server| to be BROKEN. |
117 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; | 115 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; |
118 | 116 |
119 // Returns all Alternate-Protocol mappings. | 117 // Returns all Alternate-Protocol mappings. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 155 |
158 virtual PipelineCapabilityMap GetPipelineCapabilityMap() const = 0; | 156 virtual PipelineCapabilityMap GetPipelineCapabilityMap() const = 0; |
159 | 157 |
160 private: | 158 private: |
161 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 159 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
162 }; | 160 }; |
163 | 161 |
164 } // namespace net | 162 } // namespace net |
165 | 163 |
166 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 164 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
OLD | NEW |