| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <tuple> | 12 #include <tuple> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/containers/mru_cache.h" | 15 #include "base/containers/mru_cache.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
| 20 #include "net/base/net_export.h" | 20 #include "net/base/net_export.h" |
| 21 #include "net/quic/quic_bandwidth.h" | 21 #include "net/quic/quic_bandwidth.h" |
| 22 #include "net/quic/quic_server_id.h" | 22 #include "net/quic/quic_server_id.h" |
| 23 #include "net/socket/next_proto.h" | 23 #include "net/socket/next_proto.h" |
| 24 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. | 24 #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
| 25 #include "net/spdy/spdy_protocol.h" | 25 #include "net/spdy/spdy_protocol.h" |
| 26 #include "url/scheme_host_port.h" |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 class Value; | 29 class Value; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace net { | 32 namespace net { |
| 32 | 33 |
| 33 class IPAddress; | 34 class IPAddress; |
| 34 struct SSLConfig; | 35 struct SSLConfig; |
| 35 | 36 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool operator!=(const ServerNetworkStats& other) const { | 197 bool operator!=(const ServerNetworkStats& other) const { |
| 197 return !this->operator==(other); | 198 return !this->operator==(other); |
| 198 } | 199 } |
| 199 | 200 |
| 200 base::TimeDelta srtt; | 201 base::TimeDelta srtt; |
| 201 QuicBandwidth bandwidth_estimate; | 202 QuicBandwidth bandwidth_estimate; |
| 202 }; | 203 }; |
| 203 | 204 |
| 204 typedef std::vector<AlternativeService> AlternativeServiceVector; | 205 typedef std::vector<AlternativeService> AlternativeServiceVector; |
| 205 typedef std::vector<AlternativeServiceInfo> AlternativeServiceInfoVector; | 206 typedef std::vector<AlternativeServiceInfo> AlternativeServiceInfoVector; |
| 206 typedef base::MRUCache<HostPortPair, AlternativeServiceInfoVector> | 207 typedef base::MRUCache<url::SchemeHostPort, AlternativeServiceInfoVector> |
| 207 AlternativeServiceMap; | 208 AlternativeServiceMap; |
| 208 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; | 209 typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
| 209 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; | 210 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
| 210 typedef base::MRUCache<QuicServerId, std::string> QuicServerInfoMap; | 211 typedef base::MRUCache<QuicServerId, std::string> QuicServerInfoMap; |
| 211 | 212 |
| 212 // Persist 5 QUIC Servers. This is mainly used by cronet. | 213 // Persist 5 QUIC Servers. This is mainly used by cronet. |
| 213 const int kMaxQuicServersToPersist = 5; | 214 const int kMaxQuicServersToPersist = 5; |
| 214 | 215 |
| 215 extern const char kAlternateProtocolHeader[]; | 216 extern const char kAlternateProtocolHeader[]; |
| 216 extern const char kAlternativeServiceHeader[]; | 217 extern const char kAlternativeServiceHeader[]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 230 virtual ~HttpServerProperties() {} | 231 virtual ~HttpServerProperties() {} |
| 231 | 232 |
| 232 // Gets a weak pointer for this object. | 233 // Gets a weak pointer for this object. |
| 233 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; | 234 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; |
| 234 | 235 |
| 235 // Deletes all data. | 236 // Deletes all data. |
| 236 virtual void Clear() = 0; | 237 virtual void Clear() = 0; |
| 237 | 238 |
| 238 // Returns true if |server| supports a network protocol which honors | 239 // Returns true if |server| supports a network protocol which honors |
| 239 // request prioritization. | 240 // request prioritization. |
| 240 virtual bool SupportsRequestPriority(const HostPortPair& server) = 0; | 241 virtual bool SupportsRequestPriority(const url::SchemeHostPort& server) = 0; |
| 241 | 242 |
| 242 // Returns the value set by SetSupportsSpdy(). If not set, returns false. | 243 // Returns the value set by SetSupportsSpdy(). If not set, returns false. |
| 243 virtual bool GetSupportsSpdy(const HostPortPair& server) = 0; | 244 virtual bool GetSupportsSpdy(const HostPortPair& server) = 0; |
| 244 | 245 |
| 245 // Add |server| into the persistent store. Should only be called from IO | 246 // Add |server| into the persistent store. Should only be called from IO |
| 246 // thread. | 247 // thread. |
| 247 virtual void SetSupportsSpdy(const HostPortPair& server, | 248 virtual void SetSupportsSpdy(const HostPortPair& server, |
| 248 bool support_spdy) = 0; | 249 bool support_spdy) = 0; |
| 249 | 250 |
| 250 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code. | 251 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code. |
| 251 virtual bool RequiresHTTP11(const HostPortPair& server) = 0; | 252 virtual bool RequiresHTTP11(const HostPortPair& server) = 0; |
| 252 | 253 |
| 253 // Require HTTP/1.1 on subsequent connections. Not persisted. | 254 // Require HTTP/1.1 on subsequent connections. Not persisted. |
| 254 virtual void SetHTTP11Required(const HostPortPair& server) = 0; | 255 virtual void SetHTTP11Required(const HostPortPair& server) = 0; |
| 255 | 256 |
| 256 // Modify SSLConfig to force HTTP/1.1. | 257 // Modify SSLConfig to force HTTP/1.1. |
| 257 static void ForceHTTP11(SSLConfig* ssl_config); | 258 static void ForceHTTP11(SSLConfig* ssl_config); |
| 258 | 259 |
| 259 // Modify SSLConfig to force HTTP/1.1 if necessary. | 260 // Modify SSLConfig to force HTTP/1.1 if necessary. |
| 260 virtual void MaybeForceHTTP11(const HostPortPair& server, | 261 virtual void MaybeForceHTTP11(const HostPortPair& server, |
| 261 SSLConfig* ssl_config) = 0; | 262 SSLConfig* ssl_config) = 0; |
| 262 | 263 |
| 263 // Return all alternative services for |origin|, including broken ones. | 264 // Return all alternative services for |origin|, including broken ones. |
| 264 // Returned alternative services never have empty hostnames. | 265 // Returned alternative services never have empty hostnames. |
| 265 virtual AlternativeServiceVector GetAlternativeServices( | 266 virtual AlternativeServiceVector GetAlternativeServices( |
| 266 const HostPortPair& origin) = 0; | 267 const url::SchemeHostPort& origin) = 0; |
| 267 | 268 |
| 268 // Set a single alternative service for |origin|. Previous alternative | 269 // Set a single alternative service for |origin|. Previous alternative |
| 269 // services for |origin| are discarded. | 270 // services for |origin| are discarded. |
| 270 // |alternative_service.host| may be empty. | 271 // |alternative_service.host| may be empty. |
| 271 // Return true if |alternative_service_map_| is changed. | 272 // Return true if |alternative_service_map_| is changed. |
| 272 virtual bool SetAlternativeService( | 273 virtual bool SetAlternativeService( |
| 273 const HostPortPair& origin, | 274 const url::SchemeHostPort& origin, |
| 274 const AlternativeService& alternative_service, | 275 const AlternativeService& alternative_service, |
| 275 base::Time expiration) = 0; | 276 base::Time expiration) = 0; |
| 276 | 277 |
| 277 // Set alternative services for |origin|. Previous alternative services for | 278 // Set alternative services for |origin|. Previous alternative services for |
| 278 // |origin| are discarded. | 279 // |origin| are discarded. |
| 279 // Hostnames in |alternative_service_info_vector| may be empty. | 280 // Hostnames in |alternative_service_info_vector| may be empty. |
| 280 // Return true if |alternative_service_map_| is changed. | 281 // Return true if |alternative_service_map_| is changed. |
| 281 virtual bool SetAlternativeServices( | 282 virtual bool SetAlternativeServices( |
| 282 const HostPortPair& origin, | 283 const url::SchemeHostPort& origin, |
| 283 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; | 284 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; |
| 284 | 285 |
| 285 // Marks |alternative_service| as broken. | 286 // Marks |alternative_service| as broken. |
| 286 // |alternative_service.host| must not be empty. | 287 // |alternative_service.host| must not be empty. |
| 287 virtual void MarkAlternativeServiceBroken( | 288 virtual void MarkAlternativeServiceBroken( |
| 288 const AlternativeService& alternative_service) = 0; | 289 const AlternativeService& alternative_service) = 0; |
| 289 | 290 |
| 290 // Marks |alternative_service| as recently broken. | 291 // Marks |alternative_service| as recently broken. |
| 291 // |alternative_service.host| must not be empty. | 292 // |alternative_service.host| must not be empty. |
| 292 virtual void MarkAlternativeServiceRecentlyBroken( | 293 virtual void MarkAlternativeServiceRecentlyBroken( |
| 293 const AlternativeService& alternative_service) = 0; | 294 const AlternativeService& alternative_service) = 0; |
| 294 | 295 |
| 295 // Returns true iff |alternative_service| is currently broken. | 296 // Returns true iff |alternative_service| is currently broken. |
| 296 // |alternative_service.host| must not be empty. | 297 // |alternative_service.host| must not be empty. |
| 297 virtual bool IsAlternativeServiceBroken( | 298 virtual bool IsAlternativeServiceBroken( |
| 298 const AlternativeService& alternative_service) const = 0; | 299 const AlternativeService& alternative_service) const = 0; |
| 299 | 300 |
| 300 // Returns true iff |alternative_service| was recently broken. | 301 // Returns true iff |alternative_service| was recently broken. |
| 301 // |alternative_service.host| must not be empty. | 302 // |alternative_service.host| must not be empty. |
| 302 virtual bool WasAlternativeServiceRecentlyBroken( | 303 virtual bool WasAlternativeServiceRecentlyBroken( |
| 303 const AlternativeService& alternative_service) = 0; | 304 const AlternativeService& alternative_service) = 0; |
| 304 | 305 |
| 305 // Confirms that |alternative_service| is working. | 306 // Confirms that |alternative_service| is working. |
| 306 // |alternative_service.host| must not be empty. | 307 // |alternative_service.host| must not be empty. |
| 307 virtual void ConfirmAlternativeService( | 308 virtual void ConfirmAlternativeService( |
| 308 const AlternativeService& alternative_service) = 0; | 309 const AlternativeService& alternative_service) = 0; |
| 309 | 310 |
| 310 // Clear all alternative services for |origin|. | 311 // Clear all alternative services for |origin|. |
| 311 virtual void ClearAlternativeServices(const HostPortPair& origin) = 0; | 312 virtual void ClearAlternativeServices(const url::SchemeHostPort& origin) = 0; |
| 312 | 313 |
| 313 // Returns all alternative service mappings. | 314 // Returns all alternative service mappings. |
| 314 // Returned alternative services may have empty hostnames. | 315 // Returned alternative services may have empty hostnames. |
| 315 virtual const AlternativeServiceMap& alternative_service_map() const = 0; | 316 virtual const AlternativeServiceMap& alternative_service_map() const = 0; |
| 316 | 317 |
| 317 // Returns all alternative service mappings as human readable strings. | 318 // Returns all alternative service mappings as human readable strings. |
| 318 // Empty alternative service hostnames will be printed as such. | 319 // Empty alternative service hostnames will be printed as such. |
| 319 virtual scoped_ptr<base::Value> GetAlternativeServiceInfoAsValue() const = 0; | 320 virtual scoped_ptr<base::Value> GetAlternativeServiceInfoAsValue() const = 0; |
| 320 | 321 |
| 321 // Gets a reference to the SettingsMap stored for a host. | 322 // Gets a reference to the SettingsMap stored for a host. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 virtual void SetMaxServerConfigsStoredInProperties( | 373 virtual void SetMaxServerConfigsStoredInProperties( |
| 373 size_t max_server_configs_stored_in_properties) = 0; | 374 size_t max_server_configs_stored_in_properties) = 0; |
| 374 | 375 |
| 375 private: | 376 private: |
| 376 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 377 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
| 377 }; | 378 }; |
| 378 | 379 |
| 379 } // namespace net | 380 } // namespace net |
| 380 | 381 |
| 381 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 382 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| OLD | NEW |