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

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: fix compile in components 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 expirationi,
Ryan Hamilton 2017/06/07 20:52:23 nit: trailing "i"?
Zhongyi Shi 2017/06/08 23:11:16 Done.
127 uint16_t port, 127 const QuicVersionVector& advertised_versions);
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 bool EqualAdvertisedVersions(const AlternativeServiceInfo& other) const;
136
137 void set_advertised_versions(const QuicVersionVector& advertised_versions) {
138 advertised_versions_ = advertised_versions;
139 std::sort(advertised_versions_.begin(), advertised_versions_.end());
140 }
135 141
136 bool operator==(const AlternativeServiceInfo& other) const { 142 bool operator==(const AlternativeServiceInfo& other) const {
137 return alternative_service == other.alternative_service && 143 return alternative_service == other.alternative_service &&
138 expiration == other.expiration; 144 expiration == other.expiration && EqualAdvertisedVersions(other);
Ryan Hamilton 2017/06/07 20:52:23 can you just use advertised_versions == other.adve
Zhongyi Shi 2017/06/08 23:11:16 DONE. I was trying to skip the versions compariso
139 } 145 }
140 146
141 bool operator!=(const AlternativeServiceInfo& other) const { 147 bool operator!=(const AlternativeServiceInfo& other) const {
142 return !this->operator==(other); 148 return !this->operator==(other);
143 } 149 }
144 150
145 std::string ToString() const; 151 std::string ToString() const;
146 152
153 const QuicVersionVector& advertised_versions() const {
154 return advertised_versions_;
155 }
Ryan Hamilton 2017/06/07 20:52:23 This is a struct not a class so the members are pu
Zhongyi Shi 2017/06/08 23:11:16 advertised_versions_ are marked as private (and I
Ryan Hamilton 2017/06/08 23:53:16 I think you're going to have to bit the bullet. Th
156
147 AlternativeService alternative_service; 157 AlternativeService alternative_service;
148 base::Time expiration; 158 base::Time expiration;
159
160 private:
161 // Lists all the QUIC versions that are advertised by the server and supported
162 // by Chrome. If empty, defaults to versions used by the current instance of
163 // the netstack.
164 // This list MUST be sorted in ascending order.
165 QuicVersionVector advertised_versions_;
149 }; 166 };
150 167
151 struct NET_EXPORT SupportsQuic { 168 struct NET_EXPORT SupportsQuic {
152 SupportsQuic() : used_quic(false) {} 169 SupportsQuic() : used_quic(false) {}
153 SupportsQuic(bool used_quic, const std::string& address) 170 SupportsQuic(bool used_quic, const std::string& address)
154 : used_quic(used_quic), 171 : used_quic(used_quic),
155 address(address) {} 172 address(address) {}
156 173
157 bool Equals(const SupportsQuic& other) const { 174 bool Equals(const SupportsQuic& other) const {
158 return used_quic == other.used_quic && address == other.address; 175 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; 261 const url::SchemeHostPort& origin) = 0;
245 262
246 // Set a single alternative service for |origin|. Previous alternative 263 // Set a single alternative service for |origin|. Previous alternative
247 // services for |origin| are discarded. 264 // services for |origin| are discarded.
248 // |alternative_service.host| may be empty. 265 // |alternative_service.host| may be empty.
249 // Return true if |alternative_service_map_| has changed significantly enough 266 // Return true if |alternative_service_map_| has changed significantly enough
250 // that it should be persisted to disk. 267 // that it should be persisted to disk.
251 virtual bool SetAlternativeService( 268 virtual bool SetAlternativeService(
252 const url::SchemeHostPort& origin, 269 const url::SchemeHostPort& origin,
253 const AlternativeService& alternative_service, 270 const AlternativeService& alternative_service,
254 base::Time expiration) = 0; 271 base::Time expiration,
272 const QuicVersionVector& advertised_versions) = 0;
255 273
256 // Set alternative services for |origin|. Previous alternative services for 274 // Set alternative services for |origin|. Previous alternative services for
257 // |origin| are discarded. 275 // |origin| are discarded.
258 // Hostnames in |alternative_service_info_vector| may be empty. 276 // Hostnames in |alternative_service_info_vector| may be empty.
259 // |alternative_service_info_vector| may be empty. 277 // |alternative_service_info_vector| may be empty.
260 // Return true if |alternative_service_map_| has changed significantly enough 278 // Return true if |alternative_service_map_| has changed significantly enough
261 // that it should be persisted to disk. 279 // that it should be persisted to disk.
262 virtual bool SetAlternativeServices( 280 virtual bool SetAlternativeServices(
263 const url::SchemeHostPort& origin, 281 const url::SchemeHostPort& origin,
264 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; 282 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. 355 // Returns whether HttpServerProperties is initialized.
338 virtual bool IsInitialized() const = 0; 356 virtual bool IsInitialized() const = 0;
339 357
340 private: 358 private:
341 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 359 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
342 }; 360 };
343 361
344 } // namespace net 362 } // namespace net
345 363
346 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 364 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698