[email protected] | 39c48fc | 2012-03-12 18:42:12 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| 6 | #define NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
| 7 | |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 8 | #include <map> |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 9 | #include <string> |
jsbell | cea42a5 | 2015-11-30 23:50:25 | [diff] [blame^] | 10 | #include <tuple> |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 13 | #include "base/basictypes.h" |
[email protected] | 9801e370 | 2014-03-07 09:33:55 | [diff] [blame] | 14 | #include "base/containers/mru_cache.h" |
[email protected] | 30d4c02 | 2013-07-18 22:58:16 | [diff] [blame] | 15 | #include "base/memory/weak_ptr.h" |
[email protected] | 3b8cf7f | 2014-01-27 22:08:51 | [diff] [blame] | 16 | #include "base/time/time.h" |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 17 | #include "net/base/host_port_pair.h" |
tfarina | 73144d1 | 2015-10-13 00:29:58 | [diff] [blame] | 18 | #include "net/base/ip_address_number.h" |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 19 | #include "net/base/net_export.h" |
pkasting | a9f22d4e | 2014-12-01 22:43:46 | [diff] [blame] | 20 | #include "net/quic/quic_bandwidth.h" |
rtenneti | 8b673f7 | 2015-10-08 23:45:37 | [diff] [blame] | 21 | #include "net/quic/quic_server_id.h" |
[email protected] | 0ce3af8 | 2013-07-22 16:17:16 | [diff] [blame] | 22 | #include "net/socket/next_proto.h" |
[email protected] | 53bfa31c | 2011-11-15 19:20:31 | [diff] [blame] | 23 | #include "net/spdy/spdy_framer.h" // TODO(willchan): Reconsider this. |
bnc | 1fd9133 | 2014-10-28 20:30:00 | [diff] [blame] | 24 | #include "net/spdy/spdy_protocol.h" |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 25 | |
bnc | 8ba74a178 | 2015-04-14 17:42:08 | [diff] [blame] | 26 | namespace base { |
| 27 | class Value; |
| 28 | } |
| 29 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 30 | namespace net { |
| 31 | |
bnc | facdd85 | 2015-01-09 19:22:54 | [diff] [blame] | 32 | struct SSLConfig; |
| 33 | |
[email protected] | db9bfea | 2014-04-11 18:51:39 | [diff] [blame] | 34 | enum AlternateProtocolUsage { |
| 35 | // Alternate Protocol was used without racing a normal connection. |
| 36 | ALTERNATE_PROTOCOL_USAGE_NO_RACE = 0, |
| 37 | // Alternate Protocol was used by winning a race with a normal connection. |
| 38 | ALTERNATE_PROTOCOL_USAGE_WON_RACE = 1, |
| 39 | // Alternate Protocol was not used by losing a race with a normal connection. |
| 40 | ALTERNATE_PROTOCOL_USAGE_LOST_RACE = 2, |
| 41 | // Alternate Protocol was not used because no Alternate-Protocol information |
| 42 | // was available when the request was issued, but an Alternate-Protocol header |
| 43 | // was present in the response. |
| 44 | ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING = 3, |
| 45 | // Alternate Protocol was not used because it was marked broken. |
| 46 | ALTERNATE_PROTOCOL_USAGE_BROKEN = 4, |
| 47 | // Maximum value for the enum. |
| 48 | ALTERNATE_PROTOCOL_USAGE_MAX, |
| 49 | }; |
| 50 | |
rtenneti | 7a6c3e8 | 2014-10-24 07:26:18 | [diff] [blame] | 51 | // Log a histogram to reflect |usage|. |
| 52 | NET_EXPORT void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage); |
[email protected] | db9bfea | 2014-04-11 18:51:39 | [diff] [blame] | 53 | |
[email protected] | 7b33037f | 2014-04-11 23:00:28 | [diff] [blame] | 54 | enum BrokenAlternateProtocolLocation { |
| 55 | BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB = 0, |
| 56 | BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY = 1, |
[email protected] | 00c159f | 2014-05-21 22:38:16 | [diff] [blame] | 57 | BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_ALT = 2, |
| 58 | BROKEN_ALTERNATE_PROTOCOL_LOCATION_HTTP_STREAM_FACTORY_IMPL_JOB_MAIN = 3, |
[email protected] | 7b33037f | 2014-04-11 23:00:28 | [diff] [blame] | 59 | BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX, |
| 60 | }; |
| 61 | |
| 62 | // Log a histogram to reflect |location|. |
| 63 | NET_EXPORT void HistogramBrokenAlternateProtocolLocation( |
| 64 | BrokenAlternateProtocolLocation location); |
| 65 | |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 66 | enum AlternateProtocol { |
[email protected] | b05bcaa3 | 2013-10-06 05:26:02 | [diff] [blame] | 67 | DEPRECATED_NPN_SPDY_2 = 0, |
| 68 | ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION = DEPRECATED_NPN_SPDY_2, |
| 69 | NPN_SPDY_MINIMUM_VERSION = DEPRECATED_NPN_SPDY_2, |
[email protected] | 39c48fc | 2012-03-12 18:42:12 | [diff] [blame] | 70 | NPN_SPDY_3, |
[email protected] | 63bf966 | 2013-03-05 20:46:01 | [diff] [blame] | 71 | NPN_SPDY_3_1, |
bnc | 3f946d6 | 2015-07-08 21:22:03 | [diff] [blame] | 72 | NPN_HTTP_2, // HTTP/2 |
| 73 | NPN_SPDY_MAXIMUM_VERSION = NPN_HTTP_2, |
[email protected] | 7db54b8 | 2013-04-01 21:53:45 | [diff] [blame] | 74 | QUIC, |
[email protected] | 13621d6 | 2013-10-04 18:39:21 | [diff] [blame] | 75 | ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION = QUIC, |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 76 | UNINITIALIZED_ALTERNATE_PROTOCOL, |
| 77 | }; |
| 78 | |
[email protected] | 13621d6 | 2013-10-04 18:39:21 | [diff] [blame] | 79 | // Simply returns whether |protocol| is between |
| 80 | // ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION and |
| 81 | // ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION (inclusive). |
| 82 | NET_EXPORT bool IsAlternateProtocolValid(AlternateProtocol protocol); |
| 83 | |
| 84 | enum AlternateProtocolSize { |
| 85 | NUM_VALID_ALTERNATE_PROTOCOLS = |
| 86 | ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION - |
| 87 | ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION + 1, |
| 88 | }; |
| 89 | |
[email protected] | 04af25f6 | 2012-04-10 19:11:39 | [diff] [blame] | 90 | NET_EXPORT const char* AlternateProtocolToString(AlternateProtocol protocol); |
| 91 | NET_EXPORT AlternateProtocol AlternateProtocolFromString( |
[email protected] | 13621d6 | 2013-10-04 18:39:21 | [diff] [blame] | 92 | const std::string& str); |
[email protected] | 0ce3af8 | 2013-07-22 16:17:16 | [diff] [blame] | 93 | NET_EXPORT_PRIVATE AlternateProtocol AlternateProtocolFromNextProto( |
| 94 | NextProto next_proto); |
[email protected] | 04af25f6 | 2012-04-10 19:11:39 | [diff] [blame] | 95 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 96 | // (protocol, host, port) triple as defined in |
| 97 | // https://tools.ietf.org/id/draft-ietf-httpbis-alt-svc-06.html |
bnc | 4438776 | 2015-03-09 18:00:20 | [diff] [blame] | 98 | struct NET_EXPORT AlternativeService { |
| 99 | AlternativeService() |
| 100 | : protocol(UNINITIALIZED_ALTERNATE_PROTOCOL), host(), port(0) {} |
| 101 | |
| 102 | AlternativeService(AlternateProtocol protocol, |
| 103 | const std::string& host, |
| 104 | uint16 port) |
| 105 | : protocol(protocol), host(host), port(port) {} |
| 106 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 107 | AlternativeService(AlternateProtocol protocol, |
| 108 | const HostPortPair& host_port_pair) |
| 109 | : protocol(protocol), |
| 110 | host(host_port_pair.host()), |
| 111 | port(host_port_pair.port()) {} |
| 112 | |
bnc | 4438776 | 2015-03-09 18:00:20 | [diff] [blame] | 113 | AlternativeService(const AlternativeService& alternative_service) = default; |
| 114 | AlternativeService& operator=(const AlternativeService& alternative_service) = |
| 115 | default; |
| 116 | |
bnc | 6298e99 | 2015-06-04 12:17:40 | [diff] [blame] | 117 | HostPortPair host_port_pair() const { return HostPortPair(host, port); } |
bnc | 62a44f02 | 2015-04-02 15:59:41 | [diff] [blame] | 118 | |
bnc | 127681f | 2015-03-09 23:23:49 | [diff] [blame] | 119 | bool operator==(const AlternativeService& other) const { |
| 120 | return protocol == other.protocol && host == other.host && |
| 121 | port == other.port; |
| 122 | } |
| 123 | |
rtenneti | 56dea0b | 2015-06-04 01:01:08 | [diff] [blame] | 124 | bool operator!=(const AlternativeService& other) const { |
| 125 | return !this->operator==(other); |
| 126 | } |
| 127 | |
bnc | 4438776 | 2015-03-09 18:00:20 | [diff] [blame] | 128 | bool operator<(const AlternativeService& other) const { |
jsbell | cea42a5 | 2015-11-30 23:50:25 | [diff] [blame^] | 129 | return std::tie(protocol, host, port) < |
| 130 | std::tie(other.protocol, other.host, other.port); |
bnc | 4438776 | 2015-03-09 18:00:20 | [diff] [blame] | 131 | } |
| 132 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 133 | std::string ToString() const; |
| 134 | |
bnc | 4438776 | 2015-03-09 18:00:20 | [diff] [blame] | 135 | AlternateProtocol protocol; |
| 136 | std::string host; |
| 137 | uint16 port; |
| 138 | }; |
| 139 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 140 | struct NET_EXPORT AlternativeServiceInfo { |
| 141 | AlternativeServiceInfo() : alternative_service(), probability(0.0) {} |
bnc | 97aff32a | 2015-02-02 20:17:03 | [diff] [blame] | 142 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 143 | AlternativeServiceInfo(const AlternativeService& alternative_service, |
bnc | 7dc7e1b4 | 2015-07-28 14:43:12 | [diff] [blame] | 144 | double probability, |
| 145 | base::Time expiration) |
| 146 | : alternative_service(alternative_service), |
| 147 | probability(probability), |
| 148 | expiration(expiration) {} |
[email protected] | 287d941 | 2014-07-08 23:01:00 | [diff] [blame] | 149 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 150 | AlternativeServiceInfo(AlternateProtocol protocol, |
| 151 | const std::string& host, |
| 152 | uint16 port, |
bnc | 7dc7e1b4 | 2015-07-28 14:43:12 | [diff] [blame] | 153 | double probability, |
| 154 | base::Time expiration) |
| 155 | : alternative_service(protocol, host, port), |
| 156 | probability(probability), |
| 157 | expiration(expiration) {} |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 158 | |
| 159 | AlternativeServiceInfo( |
| 160 | const AlternativeServiceInfo& alternative_service_info) = default; |
| 161 | AlternativeServiceInfo& operator=( |
| 162 | const AlternativeServiceInfo& alternative_service_info) = default; |
| 163 | |
| 164 | bool operator==(const AlternativeServiceInfo& other) const { |
| 165 | return alternative_service == other.alternative_service && |
bnc | 7dc7e1b4 | 2015-07-28 14:43:12 | [diff] [blame] | 166 | probability == other.probability && expiration == other.expiration; |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | bool operator!=(const AlternativeServiceInfo& other) const { |
| 170 | return !this->operator==(other); |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | std::string ToString() const; |
| 174 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 175 | AlternativeService alternative_service; |
[email protected] | 287d941 | 2014-07-08 23:01:00 | [diff] [blame] | 176 | double probability; |
bnc | 7dc7e1b4 | 2015-07-28 14:43:12 | [diff] [blame] | 177 | base::Time expiration; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 178 | }; |
| 179 | |
rtenneti | 1c863aa | 2014-09-25 18:39:33 | [diff] [blame] | 180 | struct NET_EXPORT SupportsQuic { |
| 181 | SupportsQuic() : used_quic(false) {} |
| 182 | SupportsQuic(bool used_quic, const std::string& address) |
| 183 | : used_quic(used_quic), |
| 184 | address(address) {} |
| 185 | |
| 186 | bool Equals(const SupportsQuic& other) const { |
| 187 | return used_quic == other.used_quic && address == other.address; |
| 188 | } |
| 189 | |
| 190 | bool used_quic; |
| 191 | std::string address; |
| 192 | }; |
| 193 | |
rtenneti | 338cd36a | 2015-01-06 00:20:07 | [diff] [blame] | 194 | struct NET_EXPORT ServerNetworkStats { |
| 195 | ServerNetworkStats() : bandwidth_estimate(QuicBandwidth::Zero()) {} |
| 196 | |
rtenneti | cce34d5 | 2015-06-05 23:36:29 | [diff] [blame] | 197 | bool operator==(const ServerNetworkStats& other) const { |
| 198 | return srtt == other.srtt && bandwidth_estimate == other.bandwidth_estimate; |
| 199 | } |
| 200 | |
| 201 | bool operator!=(const ServerNetworkStats& other) const { |
| 202 | return !this->operator==(other); |
| 203 | } |
| 204 | |
rtenneti | 338cd36a | 2015-01-06 00:20:07 | [diff] [blame] | 205 | base::TimeDelta srtt; |
| 206 | QuicBandwidth bandwidth_estimate; |
| 207 | }; |
| 208 | |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 209 | typedef std::vector<AlternativeService> AlternativeServiceVector; |
| 210 | typedef std::vector<AlternativeServiceInfo> AlternativeServiceInfoVector; |
| 211 | typedef base::MRUCache<HostPortPair, AlternativeServiceInfoVector> |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 212 | AlternativeServiceMap; |
[email protected] | 1741c94 | 2014-03-18 07:33:39 | [diff] [blame] | 213 | typedef base::MRUCache<HostPortPair, SettingsMap> SpdySettingsMap; |
rtenneti | 338cd36a | 2015-01-06 00:20:07 | [diff] [blame] | 214 | typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; |
rtenneti | 8b673f7 | 2015-10-08 23:45:37 | [diff] [blame] | 215 | typedef base::MRUCache<QuicServerId, std::string> QuicServerInfoMap; |
| 216 | |
| 217 | // Persist 5 QUIC Servers. This is mainly used by cronet. |
| 218 | const int kMaxQuicServersToPersist = 5; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 219 | |
| 220 | extern const char kAlternateProtocolHeader[]; |
bnc | c958faa | 2015-07-31 18:14:52 | [diff] [blame] | 221 | extern const char kAlternativeServiceHeader[]; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 222 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 223 | // The interface for setting/retrieving the HTTP server properties. |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 224 | // Currently, this class manages servers': |
rtenneti | cd2aaa15b | 2015-10-10 20:29:33 | [diff] [blame] | 225 | // * SPDY support (based on NPN results). |
| 226 | // * alternative service support. |
| 227 | // * SPDY Settings (like CWND ID field). |
| 228 | // * QUIC data (like ServerNetworkStats and QuicServerInfo). |
| 229 | // |
| 230 | // Embedders must ensure that HttpServerProperites is completely initialized |
| 231 | // before the first request is issued. |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 232 | class NET_EXPORT HttpServerProperties { |
| 233 | public: |
[email protected] | 41c3696d | 2012-04-08 15:22:31 | [diff] [blame] | 234 | HttpServerProperties() {} |
| 235 | virtual ~HttpServerProperties() {} |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 236 | |
[email protected] | 30d4c02 | 2013-07-18 22:58:16 | [diff] [blame] | 237 | // Gets a weak pointer for this object. |
| 238 | virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; |
| 239 | |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 240 | // Deletes all data. |
[email protected] | de95f92 | 2011-10-12 07:05:18 | [diff] [blame] | 241 | virtual void Clear() = 0; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 242 | |
rch | 9c3e338 | 2015-01-30 23:57:32 | [diff] [blame] | 243 | // Returns true if |server| supports a network protocol which honors |
| 244 | // request prioritization. |
| 245 | virtual bool SupportsRequestPriority(const HostPortPair& server) = 0; |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 246 | |
rtenneti | e267d6a | 2015-06-05 21:55:23 | [diff] [blame] | 247 | // Returns the value set by SetSupportsSpdy(). If not set, returns false. |
| 248 | virtual bool GetSupportsSpdy(const HostPortPair& server) = 0; |
| 249 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 250 | // Add |server| into the persistent store. Should only be called from IO |
| 251 | // thread. |
| 252 | virtual void SetSupportsSpdy(const HostPortPair& server, |
| 253 | bool support_spdy) = 0; |
| 254 | |
bnc | facdd85 | 2015-01-09 19:22:54 | [diff] [blame] | 255 | // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code. |
| 256 | virtual bool RequiresHTTP11(const HostPortPair& server) = 0; |
| 257 | |
| 258 | // Require HTTP/1.1 on subsequent connections. Not persisted. |
| 259 | virtual void SetHTTP11Required(const HostPortPair& server) = 0; |
| 260 | |
| 261 | // Modify SSLConfig to force HTTP/1.1. |
| 262 | static void ForceHTTP11(SSLConfig* ssl_config); |
| 263 | |
| 264 | // Modify SSLConfig to force HTTP/1.1 if necessary. |
| 265 | virtual void MaybeForceHTTP11(const HostPortPair& server, |
| 266 | SSLConfig* ssl_config) = 0; |
| 267 | |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 268 | // Return all alternative services for |origin| with probability greater than |
| 269 | // or equal to the threshold, including broken ones. |
| 270 | // Returned alternative services never have empty hostnames. |
| 271 | virtual AlternativeServiceVector GetAlternativeServices( |
bnc | 181b39a | 2015-03-17 21:36:47 | [diff] [blame] | 272 | const HostPortPair& origin) = 0; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 273 | |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 274 | // Set a single alternative service for |origin|. Previous alternative |
| 275 | // services for |origin| are discarded. |
| 276 | // |alternative_service.host| may be empty. |
| 277 | // Return true if |alternative_service_map_| is changed. |
| 278 | virtual bool SetAlternativeService( |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 279 | const HostPortPair& origin, |
| 280 | const AlternativeService& alternative_service, |
bnc | 7dc7e1b4 | 2015-07-28 14:43:12 | [diff] [blame] | 281 | double alternative_probability, |
| 282 | base::Time expiration) = 0; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 283 | |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 284 | // Set alternative services for |origin|. Previous alternative services for |
| 285 | // |origin| are discarded. |
| 286 | // Hostnames in |alternative_service_info_vector| may be empty. |
| 287 | // Return true if |alternative_service_map_| is changed. |
| 288 | virtual bool SetAlternativeServices( |
| 289 | const HostPortPair& origin, |
| 290 | const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; |
| 291 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 292 | // Marks |alternative_service| as broken. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 293 | // |alternative_service.host| must not be empty. |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 294 | virtual void MarkAlternativeServiceBroken( |
| 295 | const AlternativeService& alternative_service) = 0; |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 296 | |
bnc | d1e0aa2 | 2015-03-13 10:14:31 | [diff] [blame] | 297 | // Marks |alternative_service| as recently broken. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 298 | // |alternative_service.host| must not be empty. |
bnc | d1e0aa2 | 2015-03-13 10:14:31 | [diff] [blame] | 299 | virtual void MarkAlternativeServiceRecentlyBroken( |
| 300 | const AlternativeService& alternative_service) = 0; |
| 301 | |
bnc | 8445b300 | 2015-03-13 01:57:09 | [diff] [blame] | 302 | // Returns true iff |alternative_service| is currently broken. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 303 | // |alternative_service.host| must not be empty. |
bnc | 8445b300 | 2015-03-13 01:57:09 | [diff] [blame] | 304 | virtual bool IsAlternativeServiceBroken( |
bnc | 8ba74a178 | 2015-04-14 17:42:08 | [diff] [blame] | 305 | const AlternativeService& alternative_service) const = 0; |
bnc | 8445b300 | 2015-03-13 01:57:09 | [diff] [blame] | 306 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 307 | // Returns true iff |alternative_service| was recently broken. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 308 | // |alternative_service.host| must not be empty. |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 309 | virtual bool WasAlternativeServiceRecentlyBroken( |
| 310 | const AlternativeService& alternative_service) = 0; |
[email protected] | f5716e3 | 2014-04-18 00:44:16 | [diff] [blame] | 311 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 312 | // Confirms that |alternative_service| is working. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 313 | // |alternative_service.host| must not be empty. |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 314 | virtual void ConfirmAlternativeService( |
| 315 | const AlternativeService& alternative_service) = 0; |
[email protected] | f5716e3 | 2014-04-18 00:44:16 | [diff] [blame] | 316 | |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 317 | // Clear all alternative services for |origin|. |
| 318 | virtual void ClearAlternativeServices(const HostPortPair& origin) = 0; |
[email protected] | 90276a15 | 2014-03-06 10:20:41 | [diff] [blame] | 319 | |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 320 | // Returns all alternative service mappings. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 321 | // Returned alternative services may have empty hostnames. |
bnc | 4988e43 | 2015-03-31 03:06:25 | [diff] [blame] | 322 | virtual const AlternativeServiceMap& alternative_service_map() const = 0; |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 323 | |
bnc | 8ba74a178 | 2015-04-14 17:42:08 | [diff] [blame] | 324 | // Returns all alternative service mappings as human readable strings. |
bnc | d9b132e | 2015-07-08 05:16:10 | [diff] [blame] | 325 | // Empty alternative service hostnames will be printed as such. |
ketan.goyal | d822f5ad | 2015-06-04 04:32:08 | [diff] [blame] | 326 | virtual scoped_ptr<base::Value> GetAlternativeServiceInfoAsValue() const = 0; |
bnc | 8ba74a178 | 2015-04-14 17:42:08 | [diff] [blame] | 327 | |
bnc | cacc099 | 2015-03-20 20:22:22 | [diff] [blame] | 328 | // Sets the threshold to be used when evaluating alternative service |
| 329 | // advertisments. Only advertisements with a probability greater than or equal |
| 330 | // to |threshold| will be honored. |threshold| must be between 0.0 and 1.0 |
| 331 | // inclusive. Hence, a threshold of 0.0 implies that all advertisements will |
| 332 | // be honored. |
bnc | 62891a5 | 2015-04-27 14:14:12 | [diff] [blame] | 333 | virtual void SetAlternativeServiceProbabilityThreshold(double threshold) = 0; |
[email protected] | 287d941 | 2014-07-08 23:01:00 | [diff] [blame] | 334 | |
[email protected] | e0935cc | 2012-03-24 14:12:48 | [diff] [blame] | 335 | // Gets a reference to the SettingsMap stored for a host. |
| 336 | // If no settings are stored, returns an empty SettingsMap. |
| 337 | virtual const SettingsMap& GetSpdySettings( |
[email protected] | 1741c94 | 2014-03-18 07:33:39 | [diff] [blame] | 338 | const HostPortPair& host_port_pair) = 0; |
[email protected] | 53bfa31c | 2011-11-15 19:20:31 | [diff] [blame] | 339 | |
[email protected] | e0935cc | 2012-03-24 14:12:48 | [diff] [blame] | 340 | // Saves an individual SPDY setting for a host. Returns true if SPDY setting |
| 341 | // is to be persisted. |
[email protected] | 39c48fc | 2012-03-12 18:42:12 | [diff] [blame] | 342 | virtual bool SetSpdySetting(const HostPortPair& host_port_pair, |
[email protected] | e0935cc | 2012-03-24 14:12:48 | [diff] [blame] | 343 | SpdySettingsIds id, |
| 344 | SpdySettingsFlags flags, |
| 345 | uint32 value) = 0; |
[email protected] | 39c48fc | 2012-03-12 18:42:12 | [diff] [blame] | 346 | |
[email protected] | 6dd1134e | 2013-04-30 21:13:09 | [diff] [blame] | 347 | // Clears all SPDY settings for a host. |
| 348 | virtual void ClearSpdySettings(const HostPortPair& host_port_pair) = 0; |
| 349 | |
| 350 | // Clears all SPDY settings for all hosts. |
| 351 | virtual void ClearAllSpdySettings() = 0; |
[email protected] | 53bfa31c | 2011-11-15 19:20:31 | [diff] [blame] | 352 | |
[email protected] | e0935cc | 2012-03-24 14:12:48 | [diff] [blame] | 353 | // Returns all persistent SPDY settings. |
[email protected] | 53bfa31c | 2011-11-15 19:20:31 | [diff] [blame] | 354 | virtual const SpdySettingsMap& spdy_settings_map() const = 0; |
| 355 | |
rch | a5a10a8 | 2015-02-04 23:04:41 | [diff] [blame] | 356 | virtual bool GetSupportsQuic(IPAddressNumber* last_address) const = 0; |
rtenneti | 1c863aa | 2014-09-25 18:39:33 | [diff] [blame] | 357 | |
rch | a5a10a8 | 2015-02-04 23:04:41 | [diff] [blame] | 358 | virtual void SetSupportsQuic(bool used_quic, |
| 359 | const IPAddressNumber& last_address) = 0; |
rtenneti | 1c863aa | 2014-09-25 18:39:33 | [diff] [blame] | 360 | |
rtenneti | cce34d5 | 2015-06-05 23:36:29 | [diff] [blame] | 361 | // Sets |stats| for |host_port_pair|. |
[email protected] | 3b8cf7f | 2014-01-27 22:08:51 | [diff] [blame] | 362 | virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, |
rtenneti | 338cd36a | 2015-01-06 00:20:07 | [diff] [blame] | 363 | ServerNetworkStats stats) = 0; |
[email protected] | 3b8cf7f | 2014-01-27 22:08:51 | [diff] [blame] | 364 | |
rtenneti | 338cd36a | 2015-01-06 00:20:07 | [diff] [blame] | 365 | virtual const ServerNetworkStats* GetServerNetworkStats( |
| 366 | const HostPortPair& host_port_pair) = 0; |
| 367 | |
| 368 | virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; |
[email protected] | 3b8cf7f | 2014-01-27 22:08:51 | [diff] [blame] | 369 | |
rtenneti | 8b673f7 | 2015-10-08 23:45:37 | [diff] [blame] | 370 | // Save QuicServerInfo (in std::string form) for the given |server_id|. |
| 371 | // Returns true if the value has changed otherwise it returns false. |
| 372 | virtual bool SetQuicServerInfo(const QuicServerId& server_id, |
| 373 | const std::string& server_info) = 0; |
| 374 | |
| 375 | // Get QuicServerInfo (in std::string form) for the given |server_id|. |
| 376 | virtual const std::string* GetQuicServerInfo( |
| 377 | const QuicServerId& server_id) = 0; |
| 378 | |
| 379 | // Returns all persistent QuicServerInfo objects. |
| 380 | virtual const QuicServerInfoMap& quic_server_info_map() const = 0; |
| 381 | |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 382 | private: |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 383 | DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
| 384 | }; |
| 385 | |
| 386 | } // namespace net |
| 387 | |
| 388 | #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |