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" | 11 #include "base/containers/mru_cache.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 16 #include "net/base/net_util.h" |
16 #include "net/quic/quic_bandwidth.h" | 17 #include "net/quic/quic_bandwidth.h" |
17 #include "net/socket/next_proto.h" | 18 #include "net/socket/next_proto.h" |
18 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. | 19 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
19 #include "net/spdy/spdy_protocol.h" | 20 #include "net/spdy/spdy_protocol.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 struct SSLConfig; | 24 struct SSLConfig; |
24 | 25 |
25 enum AlternateProtocolUsage { | 26 enum AlternateProtocolUsage { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 struct NET_EXPORT ServerNetworkStats { | 141 struct NET_EXPORT ServerNetworkStats { |
141 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} | 142 ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} |
142 | 143 |
143 base::TimeDelta srtt; | 144 base::TimeDelta srtt; |
144 QuicBandwidth bandwidth_estimate; | 145 QuicBandwidth bandwidth_estimate; |
145 }; | 146 }; |
146 | 147 |
147 typedef base::MRUCache< | 148 typedef base::MRUCache< |
148 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; | 149 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; |
149 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; | 150 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
150 typedef std::map<HostPortPair, SupportsQuic> SupportsQuicMap; | |
151 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; | 151 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
152 | 152 |
153 extern const char kAlternateProtocolHeader[]; | 153 extern const char kAlternateProtocolHeader[]; |
154 | 154 |
155 // The interface for setting/retrieving the HTTP server properties. | 155 // The interface for setting/retrieving the HTTP server properties. |
156 // Currently, this class manages servers': | 156 // Currently, this class manages servers': |
157 // * SPDY support (based on NPN results) | 157 // * SPDY support (based on NPN results) |
158 // * Alternate-Protocol support | 158 // * Alternate-Protocol support |
159 // * Spdy Settings (like CWND ID field) | 159 // * Spdy Settings (like CWND ID field) |
160 class NET_EXPORT HttpServerProperties { | 160 class NET_EXPORT HttpServerProperties { |
(...skipping 22 matching lines...) Expand all Loading... |
183 // Require HTTP/1.1 on subsequent connections. Not persisted. | 183 // Require HTTP/1.1 on subsequent connections. Not persisted. |
184 virtual void SetHTTP11Required(const HostPortPair& server) = 0; | 184 virtual void SetHTTP11Required(const HostPortPair& server) = 0; |
185 | 185 |
186 // Modify SSLConfig to force HTTP/1.1. | 186 // Modify SSLConfig to force HTTP/1.1. |
187 static void ForceHTTP11(SSLConfig* ssl_config); | 187 static void ForceHTTP11(SSLConfig* ssl_config); |
188 | 188 |
189 // Modify SSLConfig to force HTTP/1.1 if necessary. | 189 // Modify SSLConfig to force HTTP/1.1 if necessary. |
190 virtual void MaybeForceHTTP11(const HostPortPair& server, | 190 virtual void MaybeForceHTTP11(const HostPortPair& server, |
191 SSLConfig* ssl_config) = 0; | 191 SSLConfig* ssl_config) = 0; |
192 | 192 |
193 // Returns true if |server| has an Alternate-Protocol header. | 193 // Returns the AlternateProtocol for |server| if it has probability equal to |
194 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; | 194 // or exceeding threshold, or else the forced AlternateProtocol if there is |
195 | 195 // one, or else one with UNINITIALIZED_ALTERNATE_PROTOCOL. |
196 // Returns the Alternate-Protocol and port for |server|. | |
197 // HasAlternateProtocol(server) must be true. | |
198 virtual AlternateProtocolInfo GetAlternateProtocol( | 196 virtual AlternateProtocolInfo GetAlternateProtocol( |
199 const HostPortPair& server) = 0; | 197 const HostPortPair& server) = 0; |
200 | 198 |
201 // Sets the Alternate-Protocol for |server|. | 199 // Sets the Alternate-Protocol for |server|. |
202 virtual void SetAlternateProtocol(const HostPortPair& server, | 200 virtual void SetAlternateProtocol(const HostPortPair& server, |
203 uint16 alternate_port, | 201 uint16 alternate_port, |
204 AlternateProtocol alternate_protocol, | 202 AlternateProtocol alternate_protocol, |
205 double probability) = 0; | 203 double probability) = 0; |
206 | 204 |
207 // Sets the Alternate-Protocol for |server| to be BROKEN. | 205 // Sets the Alternate-Protocol for |server| to be BROKEN. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 240 |
243 // Clears all SPDY settings for a host. | 241 // Clears all SPDY settings for a host. |
244 virtual void ClearSpdySettings(const HostPortPair& host_port_pair) = 0; | 242 virtual void ClearSpdySettings(const HostPortPair& host_port_pair) = 0; |
245 | 243 |
246 // Clears all SPDY settings for all hosts. | 244 // Clears all SPDY settings for all hosts. |
247 virtual void ClearAllSpdySettings() = 0; | 245 virtual void ClearAllSpdySettings() = 0; |
248 | 246 |
249 // Returns all persistent SPDY settings. | 247 // Returns all persistent SPDY settings. |
250 virtual const SpdySettingsMap& spdy_settings_map() const = 0; | 248 virtual const SpdySettingsMap& spdy_settings_map() const = 0; |
251 | 249 |
252 // TODO(rtenneti): Make SupportsQuic a global (instead of per host_port_pair). | 250 virtual bool GetSupportsQuic(IPAddressNumber* last_address) const = 0; |
253 virtual SupportsQuic GetSupportsQuic( | |
254 const HostPortPair& host_port_pair) const = 0; | |
255 | 251 |
256 virtual void SetSupportsQuic(const HostPortPair& host_port_pair, | 252 virtual void SetSupportsQuic(bool used_quic, |
257 bool used_quic, | 253 const IPAddressNumber& last_address) = 0; |
258 const std::string& address) = 0; | |
259 | |
260 virtual const SupportsQuicMap& supports_quic_map() const = 0; | |
261 | 254 |
262 virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, | 255 virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, |
263 ServerNetworkStats stats) = 0; | 256 ServerNetworkStats stats) = 0; |
264 | 257 |
265 virtual const ServerNetworkStats* GetServerNetworkStats( | 258 virtual const ServerNetworkStats* GetServerNetworkStats( |
266 const HostPortPair& host_port_pair) = 0; | 259 const HostPortPair& host_port_pair) = 0; |
267 | 260 |
268 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; | 261 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; |
269 | 262 |
270 private: | 263 private: |
271 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 264 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
272 }; | 265 }; |
273 | 266 |
274 } // namespace net | 267 } // namespace net |
275 | 268 |
276 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 269 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
OLD | NEW |