| 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 <vector> |
| 11 |
| 10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 11 #include "base/containers/mru_cache.h" | 13 #include "base/containers/mru_cache.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 14 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
| 15 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 16 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 17 #include "net/quic/quic_bandwidth.h" | 19 #include "net/quic/quic_bandwidth.h" |
| 18 #include "net/socket/next_proto.h" | 20 #include "net/socket/next_proto.h" |
| 19 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. | 21 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 194 } |
| 193 | 195 |
| 194 bool operator!=(const ServerNetworkStats& other) const { | 196 bool operator!=(const ServerNetworkStats& other) const { |
| 195 return !this->operator==(other); | 197 return !this->operator==(other); |
| 196 } | 198 } |
| 197 | 199 |
| 198 base::TimeDelta srtt; | 200 base::TimeDelta srtt; |
| 199 QuicBandwidth bandwidth_estimate; | 201 QuicBandwidth bandwidth_estimate; |
| 200 }; | 202 }; |
| 201 | 203 |
| 202 typedef base::MRUCache<HostPortPair, AlternativeServiceInfo> | 204 typedef std::vector<AlternativeService> AlternativeServiceVector; |
| 205 typedef std::vector<AlternativeServiceInfo> AlternativeServiceInfoVector; |
| 206 typedef base::MRUCache<HostPortPair, AlternativeServiceInfoVector> |
| 203 AlternativeServiceMap; | 207 AlternativeServiceMap; |
| 204 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; | 208 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
| 205 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; | 209 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
| 206 | 210 |
| 207 extern const char kAlternateProtocolHeader[]; | 211 extern const char kAlternateProtocolHeader[]; |
| 208 | 212 |
| 209 // The interface for setting/retrieving the HTTP server properties. | 213 // The interface for setting/retrieving the HTTP server properties. |
| 210 // Currently, this class manages servers': | 214 // Currently, this class manages servers': |
| 211 // * SPDY support (based on NPN results) | 215 // * SPDY support (based on NPN results) |
| 212 // * alternative service support | 216 // * alternative service support |
| (...skipping 27 matching lines...) Expand all Loading... |
| 240 // Require HTTP/1.1 on subsequent connections. Not persisted. | 244 // Require HTTP/1.1 on subsequent connections. Not persisted. |
| 241 virtual void SetHTTP11Required(const HostPortPair& server) = 0; | 245 virtual void SetHTTP11Required(const HostPortPair& server) = 0; |
| 242 | 246 |
| 243 // Modify SSLConfig to force HTTP/1.1. | 247 // Modify SSLConfig to force HTTP/1.1. |
| 244 static void ForceHTTP11(SSLConfig* ssl_config); | 248 static void ForceHTTP11(SSLConfig* ssl_config); |
| 245 | 249 |
| 246 // Modify SSLConfig to force HTTP/1.1 if necessary. | 250 // Modify SSLConfig to force HTTP/1.1 if necessary. |
| 247 virtual void MaybeForceHTTP11(const HostPortPair& server, | 251 virtual void MaybeForceHTTP11(const HostPortPair& server, |
| 248 SSLConfig* ssl_config) = 0; | 252 SSLConfig* ssl_config) = 0; |
| 249 | 253 |
| 250 // Returns the alternative service for |origin| if it has probability equal to | 254 // Return all alternative services for |origin| with probability greater than |
| 251 // or exceeding threshold, or else the forced AlternateProtocol if there is | 255 // or equal to the threshold, including broken ones. |
| 252 // one, or else one with UNINITIALIZED_ALTERNATE_PROTOCOL. | 256 // Returned alternative services never have empty hostnames. |
| 253 virtual AlternativeService GetAlternativeService( | 257 virtual AlternativeServiceVector GetAlternativeServices( |
| 254 const HostPortPair& origin) = 0; | 258 const HostPortPair& origin) = 0; |
| 255 | 259 |
| 256 // Sets the alternative service for |origin|. | 260 // Set a single alternative service for |origin|. Previous alternative |
| 257 virtual void SetAlternativeService( | 261 // services for |origin| are discarded. |
| 262 // |alternative_service.host| may be empty. |
| 263 // Return true if |alternative_service_map_| is changed. |
| 264 virtual bool SetAlternativeService( |
| 258 const HostPortPair& origin, | 265 const HostPortPair& origin, |
| 259 const AlternativeService& alternative_service, | 266 const AlternativeService& alternative_service, |
| 260 double alternative_probability) = 0; | 267 double alternative_probability) = 0; |
| 261 | 268 |
| 269 // Set alternative services for |origin|. Previous alternative services for |
| 270 // |origin| are discarded. |
| 271 // Hostnames in |alternative_service_info_vector| may be empty. |
| 272 // Return true if |alternative_service_map_| is changed. |
| 273 virtual bool SetAlternativeServices( |
| 274 const HostPortPair& origin, |
| 275 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; |
| 276 |
| 262 // Marks |alternative_service| as broken. | 277 // Marks |alternative_service| as broken. |
| 278 // |alternative_service.host| must not be empty. |
| 263 virtual void MarkAlternativeServiceBroken( | 279 virtual void MarkAlternativeServiceBroken( |
| 264 const AlternativeService& alternative_service) = 0; | 280 const AlternativeService& alternative_service) = 0; |
| 265 | 281 |
| 266 // Marks |alternative_service| as recently broken. | 282 // Marks |alternative_service| as recently broken. |
| 283 // |alternative_service.host| must not be empty. |
| 267 virtual void MarkAlternativeServiceRecentlyBroken( | 284 virtual void MarkAlternativeServiceRecentlyBroken( |
| 268 const AlternativeService& alternative_service) = 0; | 285 const AlternativeService& alternative_service) = 0; |
| 269 | 286 |
| 270 // Returns true iff |alternative_service| is currently broken. | 287 // Returns true iff |alternative_service| is currently broken. |
| 288 // |alternative_service.host| must not be empty. |
| 271 virtual bool IsAlternativeServiceBroken( | 289 virtual bool IsAlternativeServiceBroken( |
| 272 const AlternativeService& alternative_service) const = 0; | 290 const AlternativeService& alternative_service) const = 0; |
| 273 | 291 |
| 274 // Returns true iff |alternative_service| was recently broken. | 292 // Returns true iff |alternative_service| was recently broken. |
| 293 // |alternative_service.host| must not be empty. |
| 275 virtual bool WasAlternativeServiceRecentlyBroken( | 294 virtual bool WasAlternativeServiceRecentlyBroken( |
| 276 const AlternativeService& alternative_service) = 0; | 295 const AlternativeService& alternative_service) = 0; |
| 277 | 296 |
| 278 // Confirms that |alternative_service| is working. | 297 // Confirms that |alternative_service| is working. |
| 298 // |alternative_service.host| must not be empty. |
| 279 virtual void ConfirmAlternativeService( | 299 virtual void ConfirmAlternativeService( |
| 280 const AlternativeService& alternative_service) = 0; | 300 const AlternativeService& alternative_service) = 0; |
| 281 | 301 |
| 282 // Clears the alternative service for |origin|. | 302 // Clear all alternative services for |origin|. |
| 283 virtual void ClearAlternativeService(const HostPortPair& origin) = 0; | 303 virtual void ClearAlternativeServices(const HostPortPair& origin) = 0; |
| 284 | 304 |
| 285 // Returns all alternative service mappings. | 305 // Returns all alternative service mappings. |
| 306 // Returned alternative services may have empty hostnames. |
| 286 virtual const AlternativeServiceMap& alternative_service_map() const = 0; | 307 virtual const AlternativeServiceMap& alternative_service_map() const = 0; |
| 287 | 308 |
| 288 // Returns all alternative service mappings as human readable strings. | 309 // Returns all alternative service mappings as human readable strings. |
| 310 // Empty alternative service hostnames will be printed as such. |
| 289 virtual scoped_ptr<base::Value> GetAlternativeServiceInfoAsValue() const = 0; | 311 virtual scoped_ptr<base::Value> GetAlternativeServiceInfoAsValue() const = 0; |
| 290 | 312 |
| 291 // Sets the threshold to be used when evaluating alternative service | 313 // Sets the threshold to be used when evaluating alternative service |
| 292 // advertisments. Only advertisements with a probability greater than or equal | 314 // advertisments. Only advertisements with a probability greater than or equal |
| 293 // to |threshold| will be honored. |threshold| must be between 0.0 and 1.0 | 315 // to |threshold| will be honored. |threshold| must be between 0.0 and 1.0 |
| 294 // inclusive. Hence, a threshold of 0.0 implies that all advertisements will | 316 // inclusive. Hence, a threshold of 0.0 implies that all advertisements will |
| 295 // be honored. | 317 // be honored. |
| 296 virtual void SetAlternativeServiceProbabilityThreshold(double threshold) = 0; | 318 virtual void SetAlternativeServiceProbabilityThreshold(double threshold) = 0; |
| 297 | 319 |
| 298 // Gets a reference to the SettingsMap stored for a host. | 320 // Gets a reference to the SettingsMap stored for a host. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 352 |
| 331 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; | 353 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; |
| 332 | 354 |
| 333 private: | 355 private: |
| 334 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 356 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
| 335 }; | 357 }; |
| 336 | 358 |
| 337 } // namespace net | 359 } // namespace net |
| 338 | 360 |
| 339 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 361 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| OLD | NEW |