OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 enum AlternateProtocol { | 17 enum AlternateProtocol { |
17 NPN_SPDY_1 = 0, | 18 NPN_SPDY_1 = 0, |
18 NPN_SPDY_2, | 19 NPN_SPDY_2, |
19 NUM_ALTERNATE_PROTOCOLS, | 20 NUM_ALTERNATE_PROTOCOLS, |
20 ALTERNATE_PROTOCOL_BROKEN, // The alternate protocol is known to be broken. | 21 ALTERNATE_PROTOCOL_BROKEN, // The alternate protocol is known to be broken. |
21 UNINITIALIZED_ALTERNATE_PROTOCOL, | 22 UNINITIALIZED_ALTERNATE_PROTOCOL, |
22 }; | 23 }; |
23 | 24 |
24 struct NET_EXPORT PortAlternateProtocolPair { | 25 struct NET_EXPORT PortAlternateProtocolPair { |
25 bool Equals(const PortAlternateProtocolPair& other) const { | 26 bool Equals(const PortAlternateProtocolPair& other) const { |
26 return port == other.port && protocol == other.protocol; | 27 return port == other.port && protocol == other.protocol; |
27 } | 28 } |
28 | 29 |
29 std::string ToString() const; | 30 std::string ToString() const; |
30 | 31 |
31 uint16 port; | 32 uint16 port; |
32 AlternateProtocol protocol; | 33 AlternateProtocol protocol; |
33 }; | 34 }; |
34 | 35 |
35 typedef std::map<HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; | 36 typedef std::map<HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; |
| 37 typedef std::map<HostPortPair, spdy::SpdySettings> SpdySettingsMap; |
36 | 38 |
37 extern const char kAlternateProtocolHeader[]; | 39 extern const char kAlternateProtocolHeader[]; |
38 extern const char* const kAlternateProtocolStrings[NUM_ALTERNATE_PROTOCOLS]; | 40 extern const char* const kAlternateProtocolStrings[NUM_ALTERNATE_PROTOCOLS]; |
39 | 41 |
40 // The interface for setting/retrieving the HTTP server properties. | 42 // The interface for setting/retrieving the HTTP server properties. |
41 // Currently, this class manages servers': | 43 // Currently, this class manages servers': |
42 // * SPDY support (based on NPN results) | 44 // * SPDY support (based on NPN results) |
43 // * Alternate-Protocol support | 45 // * Alternate-Protocol support |
| 46 // * Spdy Settings (like CWND ID field) |
44 class NET_EXPORT HttpServerProperties { | 47 class NET_EXPORT HttpServerProperties { |
45 public: | 48 public: |
46 HttpServerProperties() {} | 49 HttpServerProperties() {} |
47 virtual ~HttpServerProperties() {} | 50 virtual ~HttpServerProperties() {} |
48 | 51 |
49 // Deletes all data. | 52 // Deletes all data. |
50 virtual void Clear() = 0; | 53 virtual void Clear() = 0; |
51 | 54 |
52 // Returns true if |server| supports SPDY. | 55 // Returns true if |server| supports SPDY. |
53 virtual bool SupportsSpdy(const HostPortPair& server) const = 0; | 56 virtual bool SupportsSpdy(const HostPortPair& server) const = 0; |
(...skipping 15 matching lines...) Expand all Loading... |
69 virtual void SetAlternateProtocol(const HostPortPair& server, | 72 virtual void SetAlternateProtocol(const HostPortPair& server, |
70 uint16 alternate_port, | 73 uint16 alternate_port, |
71 AlternateProtocol alternate_protocol) = 0; | 74 AlternateProtocol alternate_protocol) = 0; |
72 | 75 |
73 // Sets the Alternate-Protocol for |server| to be BROKEN. | 76 // Sets the Alternate-Protocol for |server| to be BROKEN. |
74 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; | 77 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; |
75 | 78 |
76 // Returns all Alternate-Protocol mappings. | 79 // Returns all Alternate-Protocol mappings. |
77 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; | 80 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; |
78 | 81 |
| 82 // Gets a reference to the SpdySettings stored for a host. |
| 83 // If no settings are stored, returns an empty set of settings. |
| 84 virtual const spdy::SpdySettings& GetSpdySettings( |
| 85 const HostPortPair& host_port_pair) const = 0; |
| 86 |
| 87 // Saves settings for a host. Returns true if SpdySettings are to be |
| 88 // persisted. |
| 89 virtual bool SetSpdySettings(const HostPortPair& host_port_pair, |
| 90 const spdy::SpdySettings& settings) = 0; |
| 91 |
| 92 // Clears all spdy_settings. |
| 93 virtual void ClearSpdySettings() = 0; |
| 94 |
| 95 // Returns all persistent SpdySettings. |
| 96 virtual const SpdySettingsMap& spdy_settings_map() const = 0; |
| 97 |
79 private: | 98 private: |
80 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 99 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
81 }; | 100 }; |
82 | 101 |
83 } // namespace net | 102 } // namespace net |
84 | 103 |
85 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 104 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
OLD | NEW |