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 <ostream> | 11 #include <ostream> |
12 #include <string> | 12 #include <string> |
13 #include <tuple> | 13 #include <tuple> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/containers/mru_cache.h" | 16 #include "base/containers/mru_cache.h" |
17 #include "base/macros.h" | 17 #include "base/macros.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/core/quic_bandwidth.h" | 21 #include "net/quic/core/quic_bandwidth.h" |
22 #include "net/quic/core/quic_server_id.h" | 22 #include "net/quic/core/quic_server_id.h" |
| 23 #include "net/quic/core/quic_versions.h" |
23 #include "net/socket/next_proto.h" | 24 #include "net/socket/next_proto.h" |
24 #include "net/spdy/core/spdy_framer.h" // TODO(willchan): Reconsider this. | 25 #include "net/spdy/core/spdy_framer.h" // TODO(willchan): Reconsider this. |
25 #include "net/spdy/core/spdy_protocol.h" | 26 #include "net/spdy/core/spdy_protocol.h" |
26 #include "url/scheme_host_port.h" | 27 #include "url/scheme_host_port.h" |
27 | 28 |
28 namespace base { | 29 namespace base { |
29 class Value; | 30 class Value; |
30 } | 31 } |
31 | 32 |
32 namespace net { | 33 namespace net { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 std::string host; | 110 std::string host; |
110 uint16_t port; | 111 uint16_t port; |
111 }; | 112 }; |
112 | 113 |
113 NET_EXPORT_PRIVATE std::ostream& operator<<( | 114 NET_EXPORT_PRIVATE std::ostream& operator<<( |
114 std::ostream& os, | 115 std::ostream& os, |
115 const AlternativeService& alternative_service); | 116 const AlternativeService& alternative_service); |
116 | 117 |
117 class NET_EXPORT_PRIVATE AlternativeServiceInfo { | 118 class NET_EXPORT_PRIVATE AlternativeServiceInfo { |
118 public: | 119 public: |
| 120 static AlternativeServiceInfo CreateHttp2AlternativeServiceInfo( |
| 121 const AlternativeService& alternative_service, |
| 122 base::Time expiration); |
| 123 |
| 124 static AlternativeServiceInfo CreateQuicAlternativeServiceInfo( |
| 125 const AlternativeService& alternative_service, |
| 126 base::Time expiration, |
| 127 const QuicVersionVector& advertised_versions); |
| 128 |
119 AlternativeServiceInfo(); | 129 AlternativeServiceInfo(); |
120 | 130 ~AlternativeServiceInfo(); |
121 AlternativeServiceInfo(const AlternativeService& alternative_service, | |
122 base::Time expiration); | |
123 | |
124 AlternativeServiceInfo(NextProto protocol, | |
125 const std::string& host, | |
126 uint16_t port, | |
127 base::Time expiration); | |
128 | 131 |
129 AlternativeServiceInfo( | 132 AlternativeServiceInfo( |
130 const AlternativeServiceInfo& alternative_service_info); | 133 const AlternativeServiceInfo& alternative_service_info); |
| 134 |
131 AlternativeServiceInfo& operator=( | 135 AlternativeServiceInfo& operator=( |
132 const AlternativeServiceInfo& alternative_service_info); | 136 const AlternativeServiceInfo& alternative_service_info); |
133 | 137 |
134 bool operator==(const AlternativeServiceInfo& other) const { | 138 bool operator==(const AlternativeServiceInfo& other) const { |
135 return alternative_service_ == other.alternative_service() && | 139 return alternative_service_ == other.alternative_service() && |
136 expiration_ == other.expiration(); | 140 expiration_ == other.expiration() && |
| 141 advertised_versions_ == other.advertised_versions(); |
137 } | 142 } |
138 | 143 |
139 bool operator!=(const AlternativeServiceInfo& other) const { | 144 bool operator!=(const AlternativeServiceInfo& other) const { |
140 return !this->operator==(other); | 145 return !this->operator==(other); |
141 } | 146 } |
142 | 147 |
143 std::string ToString() const; | 148 std::string ToString() const; |
144 | 149 |
145 void set_alternative_service(const AlternativeService& alternative_service) { | 150 void set_alternative_service(const AlternativeService& alternative_service) { |
146 alternative_service_ = alternative_service; | 151 alternative_service_ = alternative_service; |
147 } | 152 } |
148 | 153 |
149 void set_protocol(const NextProto& protocol) { | 154 void set_protocol(const NextProto& protocol) { |
150 alternative_service_.protocol = protocol; | 155 alternative_service_.protocol = protocol; |
151 } | 156 } |
152 | 157 |
153 void set_host(const std::string& host) { alternative_service_.host = host; } | 158 void set_host(const std::string& host) { alternative_service_.host = host; } |
154 | 159 |
155 void set_port(uint16_t port) { alternative_service_.port = port; } | 160 void set_port(uint16_t port) { alternative_service_.port = port; } |
156 | 161 |
157 void set_expiration(const base::Time& expiration) { | 162 void set_expiration(const base::Time& expiration) { |
158 expiration_ = expiration; | 163 expiration_ = expiration; |
159 } | 164 } |
160 | 165 |
| 166 void set_advertised_versions(const QuicVersionVector& advertised_versions) { |
| 167 if (alternative_service_.protocol != kProtoQUIC) |
| 168 return; |
| 169 |
| 170 advertised_versions_ = advertised_versions; |
| 171 std::sort(advertised_versions_.begin(), advertised_versions_.end()); |
| 172 } |
| 173 |
161 const AlternativeService& alternative_service() const { | 174 const AlternativeService& alternative_service() const { |
162 return alternative_service_; | 175 return alternative_service_; |
163 } | 176 } |
164 | 177 |
165 base::Time expiration() const { return expiration_; } | 178 base::Time expiration() const { return expiration_; } |
166 | 179 |
| 180 const QuicVersionVector& advertised_versions() const { |
| 181 return advertised_versions_; |
| 182 } |
| 183 |
167 private: | 184 private: |
| 185 AlternativeServiceInfo(const AlternativeService& alternative_service, |
| 186 base::Time expiration, |
| 187 const QuicVersionVector& advertised_versions); |
| 188 |
168 AlternativeService alternative_service_; | 189 AlternativeService alternative_service_; |
169 base::Time expiration_; | 190 base::Time expiration_; |
| 191 |
| 192 // Lists all the QUIC versions that are advertised by the server and supported |
| 193 // by Chrome. If empty, defaults to versions used by the current instance of |
| 194 // the netstack. |
| 195 // This list MUST be sorted in ascending order. |
| 196 QuicVersionVector advertised_versions_; |
170 }; | 197 }; |
171 | 198 |
172 struct NET_EXPORT SupportsQuic { | 199 struct NET_EXPORT SupportsQuic { |
173 SupportsQuic() : used_quic(false) {} | 200 SupportsQuic() : used_quic(false) {} |
174 SupportsQuic(bool used_quic, const std::string& address) | 201 SupportsQuic(bool used_quic, const std::string& address) |
175 : used_quic(used_quic), | 202 : used_quic(used_quic), |
176 address(address) {} | 203 address(address) {} |
177 | 204 |
178 bool Equals(const SupportsQuic& other) const { | 205 bool Equals(const SupportsQuic& other) const { |
179 return used_quic == other.used_quic && address == other.address; | 206 return used_quic == other.used_quic && address == other.address; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 290 |
264 // Modify SSLConfig to force HTTP/1.1 if necessary. | 291 // Modify SSLConfig to force HTTP/1.1 if necessary. |
265 virtual void MaybeForceHTTP11(const HostPortPair& server, | 292 virtual void MaybeForceHTTP11(const HostPortPair& server, |
266 SSLConfig* ssl_config) = 0; | 293 SSLConfig* ssl_config) = 0; |
267 | 294 |
268 // Return all alternative services for |origin|, including broken ones. | 295 // Return all alternative services for |origin|, including broken ones. |
269 // Returned alternative services never have empty hostnames. | 296 // Returned alternative services never have empty hostnames. |
270 virtual AlternativeServiceInfoVector GetAlternativeServiceInfos( | 297 virtual AlternativeServiceInfoVector GetAlternativeServiceInfos( |
271 const url::SchemeHostPort& origin) = 0; | 298 const url::SchemeHostPort& origin) = 0; |
272 | 299 |
273 // Set a single alternative service for |origin|. Previous alternative | 300 // Set a single HTTP/2 alternative service for |origin|. Previous |
| 301 // alternative services for |origin| are discarded. |
| 302 // |alternative_service.host| may be empty. |
| 303 // Return true if |alternative_service_map_| has changed significantly enough |
| 304 // that it should be persisted to disk. |
| 305 virtual bool SetHttp2AlternativeService( |
| 306 const url::SchemeHostPort& origin, |
| 307 const AlternativeService& alternative_service, |
| 308 base::Time expiration) = 0; |
| 309 |
| 310 // Set a single QUIC alternative service for |origin|. Previous alternative |
274 // services for |origin| are discarded. | 311 // services for |origin| are discarded. |
275 // |alternative_service.host| may be empty. | 312 // |alternative_service.host| may be empty. |
276 // Return true if |alternative_service_map_| has changed significantly enough | 313 // Return true if |alternative_service_map_| has changed significantly enough |
277 // that it should be persisted to disk. | 314 // that it should be persisted to disk. |
278 virtual bool SetAlternativeService( | 315 virtual bool SetQuicAlternativeService( |
279 const url::SchemeHostPort& origin, | 316 const url::SchemeHostPort& origin, |
280 const AlternativeService& alternative_service, | 317 const AlternativeService& alternative_service, |
281 base::Time expiration) = 0; | 318 base::Time expiration, |
| 319 const QuicVersionVector& advertised_versions) = 0; |
282 | 320 |
283 // Set alternative services for |origin|. Previous alternative services for | 321 // Set alternative services for |origin|. Previous alternative services for |
284 // |origin| are discarded. | 322 // |origin| are discarded. |
285 // Hostnames in |alternative_service_info_vector| may be empty. | 323 // Hostnames in |alternative_service_info_vector| may be empty. |
286 // |alternative_service_info_vector| may be empty. | 324 // |alternative_service_info_vector| may be empty. |
287 // Return true if |alternative_service_map_| has changed significantly enough | 325 // Return true if |alternative_service_map_| has changed significantly enough |
288 // that it should be persisted to disk. | 326 // that it should be persisted to disk. |
289 virtual bool SetAlternativeServices( | 327 virtual bool SetAlternativeServices( |
290 const url::SchemeHostPort& origin, | 328 const url::SchemeHostPort& origin, |
291 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; | 329 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // Returns whether HttpServerProperties is initialized. | 402 // Returns whether HttpServerProperties is initialized. |
365 virtual bool IsInitialized() const = 0; | 403 virtual bool IsInitialized() const = 0; |
366 | 404 |
367 private: | 405 private: |
368 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); | 406 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); |
369 }; | 407 }; |
370 | 408 |
371 } // namespace net | 409 } // namespace net |
372 | 410 |
373 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ | 411 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ |
OLD | NEW |