Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: net/http/http_server_properties.h

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: manually fix rebase issues Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 NextProto protocol; 109 NextProto protocol;
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 struct NET_EXPORT AlternativeServiceInfo { 118 struct NET_EXPORT AlternativeServiceInfo {
118 AlternativeServiceInfo() : alternative_service() {} 119 AlternativeServiceInfo();
120 ~AlternativeServiceInfo();
119 121
120 AlternativeServiceInfo(const AlternativeService& alternative_service, 122 AlternativeServiceInfo(const AlternativeService& alternative_service,
121 base::Time expiration) 123 base::Time expiration);
122 : alternative_service(alternative_service),
123 expiration(expiration) {}
124 124
125 AlternativeServiceInfo(NextProto protocol, 125 AlternativeServiceInfo(const AlternativeService& alternative_service,
126 const std::string& host, 126 base::Time expiration,
127 uint16_t port, 127 const QuicVersionVector& advertised_versions);
xunjieli 2017/06/09 16:41:55 AlternativeService can advertise any protocol. It'
Zhongyi Shi 2017/06/16 00:24:04 As discussed offline, I hide the generic construct
128 base::Time expiration)
129 : alternative_service(protocol, host, port), expiration(expiration) {}
130 128
131 AlternativeServiceInfo( 129 AlternativeServiceInfo(
132 const AlternativeServiceInfo& alternative_service_info) = default; 130 const AlternativeServiceInfo& alternative_service_info);
131
133 AlternativeServiceInfo& operator=( 132 AlternativeServiceInfo& operator=(
134 const AlternativeServiceInfo& alternative_service_info) = default; 133 const AlternativeServiceInfo& alternative_service_info);
134
135 void set_advertised_versions(const QuicVersionVector& advertised_versions) {
136 if (alternative_service.protocol != kProtoQUIC)
137 return;
138
139 advertised_versions_ = advertised_versions;
140 std::sort(advertised_versions_.begin(), advertised_versions_.end());
141 }
135 142
136 bool operator==(const AlternativeServiceInfo& other) const { 143 bool operator==(const AlternativeServiceInfo& other) const {
137 return alternative_service == other.alternative_service && 144 return alternative_service == other.alternative_service &&
138 expiration == other.expiration; 145 expiration == other.expiration &&
146 advertised_versions_ == other.advertised_versions();
139 } 147 }
140 148
141 bool operator!=(const AlternativeServiceInfo& other) const { 149 bool operator!=(const AlternativeServiceInfo& other) const {
142 return !this->operator==(other); 150 return !this->operator==(other);
143 } 151 }
144 152
145 std::string ToString() const; 153 std::string ToString() const;
146 154
155 const QuicVersionVector& advertised_versions() const {
156 return advertised_versions_;
157 }
158
147 AlternativeService alternative_service; 159 AlternativeService alternative_service;
148 base::Time expiration; 160 base::Time expiration;
161
162 private:
163 // Lists all the QUIC versions that are advertised by the server and supported
164 // by Chrome. If empty, defaults to versions used by the current instance of
165 // the netstack.
166 // This list MUST be sorted in ascending order.
167 QuicVersionVector advertised_versions_;
149 }; 168 };
150 169
151 struct NET_EXPORT SupportsQuic { 170 struct NET_EXPORT SupportsQuic {
152 SupportsQuic() : used_quic(false) {} 171 SupportsQuic() : used_quic(false) {}
153 SupportsQuic(bool used_quic, const std::string& address) 172 SupportsQuic(bool used_quic, const std::string& address)
154 : used_quic(used_quic), 173 : used_quic(used_quic),
155 address(address) {} 174 address(address) {}
156 175
157 bool Equals(const SupportsQuic& other) const { 176 bool Equals(const SupportsQuic& other) const {
158 return used_quic == other.used_quic && address == other.address; 177 return used_quic == other.used_quic && address == other.address;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const url::SchemeHostPort& origin) = 0; 263 const url::SchemeHostPort& origin) = 0;
245 264
246 // Set a single alternative service for |origin|. Previous alternative 265 // Set a single alternative service for |origin|. Previous alternative
247 // services for |origin| are discarded. 266 // services for |origin| are discarded.
248 // |alternative_service.host| may be empty. 267 // |alternative_service.host| may be empty.
249 // Return true if |alternative_service_map_| has changed significantly enough 268 // Return true if |alternative_service_map_| has changed significantly enough
250 // that it should be persisted to disk. 269 // that it should be persisted to disk.
251 virtual bool SetAlternativeService( 270 virtual bool SetAlternativeService(
252 const url::SchemeHostPort& origin, 271 const url::SchemeHostPort& origin,
253 const AlternativeService& alternative_service, 272 const AlternativeService& alternative_service,
254 base::Time expiration) = 0; 273 base::Time expiration,
274 const QuicVersionVector& advertised_versions) = 0;
255 275
256 // Set alternative services for |origin|. Previous alternative services for 276 // Set alternative services for |origin|. Previous alternative services for
257 // |origin| are discarded. 277 // |origin| are discarded.
258 // Hostnames in |alternative_service_info_vector| may be empty. 278 // Hostnames in |alternative_service_info_vector| may be empty.
259 // |alternative_service_info_vector| may be empty. 279 // |alternative_service_info_vector| may be empty.
260 // Return true if |alternative_service_map_| has changed significantly enough 280 // Return true if |alternative_service_map_| has changed significantly enough
261 // that it should be persisted to disk. 281 // that it should be persisted to disk.
262 virtual bool SetAlternativeServices( 282 virtual bool SetAlternativeServices(
263 const url::SchemeHostPort& origin, 283 const url::SchemeHostPort& origin,
264 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; 284 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Returns whether HttpServerProperties is initialized. 357 // Returns whether HttpServerProperties is initialized.
338 virtual bool IsInitialized() const = 0; 358 virtual bool IsInitialized() const = 0;
339 359
340 private: 360 private:
341 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 361 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
342 }; 362 };
343 363
344 } // namespace net 364 } // namespace net
345 365
346 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 366 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698