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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - | 85 ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - |
86 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, | 86 ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, |
87 }; | 87 }; |
88 | 88 |
89 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); | 89 NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); |
90 NET_EXPORT AlternateProtocol AlternateProtocolFromString( | 90 NET_EXPORT AlternateProtocol AlternateProtocolFromString( |
91 const std::string& str); | 91 const std::string& str); |
92 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( | 92 NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( |
93 NextProto next_proto); | 93 NextProto next_proto); |
94 | 94 |
95 struct NET_EXPORT AlternateProtocolInfo { | 95 struct NET_EXPORT PortAlternateProtocolPair { |
96 AlternateProtocolInfo(uint16 port, | 96 bool Equals(const PortAlternateProtocolPair& other) const { |
97 AlternateProtocol protocol, | 97 return port == other.port && protocol == other.protocol; |
98 double probability) | |
99 : port(port), | |
100 protocol(protocol), | |
101 probability(probability) {} | |
102 | |
103 bool Equals(const AlternateProtocolInfo& other) const { | |
104 return port == other.port && | |
105 protocol == other.protocol && | |
106 probability == other.probability; | |
107 } | 98 } |
108 | 99 |
109 std::string ToString() const; | 100 std::string ToString() const; |
110 | 101 |
111 uint16 port; | 102 uint16 port; |
112 AlternateProtocol protocol; | 103 AlternateProtocol protocol; |
113 double probability; | |
114 }; | 104 }; |
115 | 105 |
116 typedef base::MRUCache< | 106 typedef base::MRUCache< |
117 HostPortPair, AlternateProtocolInfo> AlternateProtocolMap; | 107 HostPortPair, PortAlternateProtocolPair> AlternateProtocolMap; |
118 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; | 108 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
119 | 109 |
120 extern const char kAlternateProtocolHeader[]; | 110 extern const char kAlternateProtocolHeader[]; |
121 | 111 |
122 // The interface for setting/retrieving the HTTP server properties. | 112 // The interface for setting/retrieving the HTTP server properties. |
123 // Currently, this class manages servers': | 113 // Currently, this class manages servers': |
124 // * SPDY support (based on NPN results) | 114 // * SPDY support (based on NPN results) |
125 // * Alternate-Protocol support | 115 // * Alternate-Protocol support |
126 // * Spdy Settings (like CWND ID field) | 116 // * Spdy Settings (like CWND ID field) |
127 class NET_EXPORT HttpServerProperties { | 117 class NET_EXPORT HttpServerProperties { |
(...skipping 18 matching lines...) Expand all Loading... |
146 // Add |server| into the persistent store. Should only be called from IO | 136 // Add |server| into the persistent store. Should only be called from IO |
147 // thread. | 137 // thread. |
148 virtual void SetSupportsSpdy(const HostPortPair& server, | 138 virtual void SetSupportsSpdy(const HostPortPair& server, |
149 bool support_spdy) = 0; | 139 bool support_spdy) = 0; |
150 | 140 |
151 // Returns true if |server| has an Alternate-Protocol header. | 141 // Returns true if |server| has an Alternate-Protocol header. |
152 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; | 142 virtual bool HasAlternateProtocol(const HostPortPair& server) = 0; |
153 | 143 |
154 // Returns the Alternate-Protocol and port for |server|. | 144 // Returns the Alternate-Protocol and port for |server|. |
155 // HasAlternateProtocol(server) must be true. | 145 // HasAlternateProtocol(server) must be true. |
156 virtual AlternateProtocolInfo GetAlternateProtocol( | 146 virtual PortAlternateProtocolPair GetAlternateProtocol( |
157 const HostPortPair& server) = 0; | 147 const HostPortPair& server) = 0; |
158 | 148 |
159 // Sets the Alternate-Protocol for |server|. | 149 // Sets the Alternate-Protocol for |server|. |
160 virtual void SetAlternateProtocol(const HostPortPair& server, | 150 virtual void SetAlternateProtocol(const HostPortPair& server, |
161 uint16 alternate_port, | 151 uint16 alternate_port, |
162 AlternateProtocol alternate_protocol, | 152 AlternateProtocol alternate_protocol) = 0; |
163 double probability) = 0; | |
164 | 153 |
165 // Sets the Alternate-Protocol for |server| to be BROKEN. | 154 // Sets the Alternate-Protocol for |server| to be BROKEN. |
166 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; | 155 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) = 0; |
167 | 156 |
168 // Returns true if Alternate-Protocol for |server| was recently BROKEN. | 157 // Returns true if Alternate-Protocol for |server| was recently BROKEN. |
169 virtual bool WasAlternateProtocolRecentlyBroken( | 158 virtual bool WasAlternateProtocolRecentlyBroken( |
170 const HostPortPair& server) = 0; | 159 const HostPortPair& server) = 0; |
171 | 160 |
172 // Confirms that Alternate-Protocol for |server| is working. | 161 // Confirms that Alternate-Protocol for |server| is working. |
173 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; | 162 virtual void ConfirmAlternateProtocol(const HostPortPair& server) = 0; |
174 | 163 |
175 // Clears the Alternate-Protocol for |server|. | 164 // Clears the Alternate-Protocol for |server|. |
176 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; | 165 virtual void ClearAlternateProtocol(const HostPortPair& server) = 0; |
177 | 166 |
178 // Returns all Alternate-Protocol mappings. | 167 // Returns all Alternate-Protocol mappings. |
179 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; | 168 virtual const AlternateProtocolMap& alternate_protocol_map() const = 0; |
180 | 169 |
181 virtual void SetAlternateProtocolExperiment( | 170 virtual void SetAlternateProtocolExperiment( |
182 AlternateProtocolExperiment experiment) = 0; | 171 AlternateProtocolExperiment experiment) = 0; |
183 | 172 |
184 virtual void SetAlternateProtocolProbabilityThreshold( | |
185 double threshold) = 0; | |
186 | |
187 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment() | 173 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment() |
188 const = 0; | 174 const = 0; |
189 | 175 |
190 // Gets a reference to the SettingsMap stored for a host. | 176 // Gets a reference to the SettingsMap stored for a host. |
191 // If no settings are stored, returns an empty SettingsMap. | 177 // If no settings are stored, returns an empty SettingsMap. |
192 virtual const SettingsMap& GetSpdySettings( | 178 virtual const SettingsMap& GetSpdySettings( |
193 const HostPortPair& host_port_pair) = 0; | 179 const HostPortPair& host_port_pair) = 0; |
194 | 180 |
195 // Saves an individual SPDY setting for a host. Returns true if SPDY setting | 181 // Saves an individual SPDY setting for a host. Returns true if SPDY setting |
196 // is to be persisted. | 182 // is to be persisted. |
(...skipping 17 matching lines...) Expand all Loading... |
214 virtual const NetworkStats* GetServerNetworkStats( | 200 virtual const NetworkStats* GetServerNetworkStats( |
215 const HostPortPair& host_port_pair) const = 0; | 201 const HostPortPair& host_port_pair) const = 0; |
216 | 202 |
217 private: | 203 private: |
218 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 204 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
219 }; | 205 }; |
220 | 206 |
221 } // namespace net | 207 } // namespace net |
222 | 208 |
223 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 209 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
OLD | NEW |