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

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

Issue 1904483004: Change SupportsSpdy dict, SpdySettingsMap, ServerNetworkStatsMap, AlternativeServiceMap and disk da… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile after sync code, introduced by commit 388755 Created 4 years, 8 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
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_server_properties_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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<url::SchemeHostPort, SettingsMap> SpdySettingsMap;
209 typedef base::MRUCache<HostPortPair, ServerNetworkStats> ServerNetworkStatsMap; 210 typedef base::MRUCache<url::SchemeHostPort, ServerNetworkStats>
211 ServerNetworkStatsMap;
210 typedef base::MRUCache<QuicServerId, std::string> QuicServerInfoMap; 212 typedef base::MRUCache<QuicServerId, std::string> QuicServerInfoMap;
211 213
212 // Persist 5 QUIC Servers. This is mainly used by cronet. 214 // Persist 5 QUIC Servers. This is mainly used by cronet.
213 const int kMaxQuicServersToPersist = 5; 215 const int kMaxQuicServersToPersist = 5;
214 216
215 extern const char kAlternateProtocolHeader[]; 217 extern const char kAlternateProtocolHeader[];
216 extern const char kAlternativeServiceHeader[]; 218 extern const char kAlternativeServiceHeader[];
217 219
218 // The interface for setting/retrieving the HTTP server properties. 220 // The interface for setting/retrieving the HTTP server properties.
219 // Currently, this class manages servers': 221 // Currently, this class manages servers':
(...skipping 10 matching lines...) Expand all
230 virtual ~HttpServerProperties() {} 232 virtual ~HttpServerProperties() {}
231 233
232 // Gets a weak pointer for this object. 234 // Gets a weak pointer for this object.
233 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0; 235 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() = 0;
234 236
235 // Deletes all data. 237 // Deletes all data.
236 virtual void Clear() = 0; 238 virtual void Clear() = 0;
237 239
238 // Returns true if |server| supports a network protocol which honors 240 // Returns true if |server| supports a network protocol which honors
239 // request prioritization. 241 // request prioritization.
240 virtual bool SupportsRequestPriority(const HostPortPair& server) = 0; 242 virtual bool SupportsRequestPriority(const url::SchemeHostPort& server) = 0;
241 243
242 // Returns the value set by SetSupportsSpdy(). If not set, returns false. 244 // Returns the value set by SetSupportsSpdy(). If not set, returns false.
243 virtual bool GetSupportsSpdy(const HostPortPair& server) = 0; 245 virtual bool GetSupportsSpdy(const url::SchemeHostPort& server) = 0;
244 246
245 // Add |server| into the persistent store. Should only be called from IO 247 // Add |server| into the persistent store. Should only be called from IO
246 // thread. 248 // thread.
247 virtual void SetSupportsSpdy(const HostPortPair& server, 249 virtual void SetSupportsSpdy(const url::SchemeHostPort& server,
248 bool support_spdy) = 0; 250 bool support_spdy) = 0;
249 251
250 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code. 252 // Returns true if |server| has required HTTP/1.1 via HTTP/2 error code.
251 virtual bool RequiresHTTP11(const HostPortPair& server) = 0; 253 virtual bool RequiresHTTP11(const HostPortPair& server) = 0;
252 254
253 // Require HTTP/1.1 on subsequent connections. Not persisted. 255 // Require HTTP/1.1 on subsequent connections. Not persisted.
254 virtual void SetHTTP11Required(const HostPortPair& server) = 0; 256 virtual void SetHTTP11Required(const HostPortPair& server) = 0;
255 257
256 // Modify SSLConfig to force HTTP/1.1. 258 // Modify SSLConfig to force HTTP/1.1.
257 static void ForceHTTP11(SSLConfig* ssl_config); 259 static void ForceHTTP11(SSLConfig* ssl_config);
258 260
259 // Modify SSLConfig to force HTTP/1.1 if necessary. 261 // Modify SSLConfig to force HTTP/1.1 if necessary.
260 virtual void MaybeForceHTTP11(const HostPortPair& server, 262 virtual void MaybeForceHTTP11(const HostPortPair& server,
261 SSLConfig* ssl_config) = 0; 263 SSLConfig* ssl_config) = 0;
262 264
263 // Return all alternative services for |origin|, including broken ones. 265 // Return all alternative services for |origin|, including broken ones.
264 // Returned alternative services never have empty hostnames. 266 // Returned alternative services never have empty hostnames.
265 virtual AlternativeServiceVector GetAlternativeServices( 267 virtual AlternativeServiceVector GetAlternativeServices(
266 const HostPortPair& origin) = 0; 268 const url::SchemeHostPort& origin) = 0;
267 269
268 // Set a single alternative service for |origin|. Previous alternative 270 // Set a single alternative service for |origin|. Previous alternative
269 // services for |origin| are discarded. 271 // services for |origin| are discarded.
270 // |alternative_service.host| may be empty. 272 // |alternative_service.host| may be empty.
271 // Return true if |alternative_service_map_| is changed. 273 // Return true if |alternative_service_map_| is changed.
272 virtual bool SetAlternativeService( 274 virtual bool SetAlternativeService(
273 const HostPortPair& origin, 275 const url::SchemeHostPort& origin,
274 const AlternativeService& alternative_service, 276 const AlternativeService& alternative_service,
275 base::Time expiration) = 0; 277 base::Time expiration) = 0;
276 278
277 // Set alternative services for |origin|. Previous alternative services for 279 // Set alternative services for |origin|. Previous alternative services for
278 // |origin| are discarded. 280 // |origin| are discarded.
279 // Hostnames in |alternative_service_info_vector| may be empty. 281 // Hostnames in |alternative_service_info_vector| may be empty.
280 // Return true if |alternative_service_map_| is changed. 282 // Return true if |alternative_service_map_| is changed.
281 virtual bool SetAlternativeServices( 283 virtual bool SetAlternativeServices(
282 const HostPortPair& origin, 284 const url::SchemeHostPort& origin,
283 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0; 285 const AlternativeServiceInfoVector& alternative_service_info_vector) = 0;
284 286
285 // Marks |alternative_service| as broken. 287 // Marks |alternative_service| as broken.
286 // |alternative_service.host| must not be empty. 288 // |alternative_service.host| must not be empty.
287 virtual void MarkAlternativeServiceBroken( 289 virtual void MarkAlternativeServiceBroken(
288 const AlternativeService& alternative_service) = 0; 290 const AlternativeService& alternative_service) = 0;
289 291
290 // Marks |alternative_service| as recently broken. 292 // Marks |alternative_service| as recently broken.
291 // |alternative_service.host| must not be empty. 293 // |alternative_service.host| must not be empty.
292 virtual void MarkAlternativeServiceRecentlyBroken( 294 virtual void MarkAlternativeServiceRecentlyBroken(
293 const AlternativeService& alternative_service) = 0; 295 const AlternativeService& alternative_service) = 0;
294 296
295 // Returns true iff |alternative_service| is currently broken. 297 // Returns true iff |alternative_service| is currently broken.
296 // |alternative_service.host| must not be empty. 298 // |alternative_service.host| must not be empty.
297 virtual bool IsAlternativeServiceBroken( 299 virtual bool IsAlternativeServiceBroken(
298 const AlternativeService& alternative_service) const = 0; 300 const AlternativeService& alternative_service) const = 0;
299 301
300 // Returns true iff |alternative_service| was recently broken. 302 // Returns true iff |alternative_service| was recently broken.
301 // |alternative_service.host| must not be empty. 303 // |alternative_service.host| must not be empty.
302 virtual bool WasAlternativeServiceRecentlyBroken( 304 virtual bool WasAlternativeServiceRecentlyBroken(
303 const AlternativeService& alternative_service) = 0; 305 const AlternativeService& alternative_service) = 0;
304 306
305 // Confirms that |alternative_service| is working. 307 // Confirms that |alternative_service| is working.
306 // |alternative_service.host| must not be empty. 308 // |alternative_service.host| must not be empty.
307 virtual void ConfirmAlternativeService( 309 virtual void ConfirmAlternativeService(
308 const AlternativeService& alternative_service) = 0; 310 const AlternativeService& alternative_service) = 0;
309 311
310 // Clear all alternative services for |origin|. 312 // Clear all alternative services for |origin|.
311 virtual void ClearAlternativeServices(const HostPortPair& origin) = 0; 313 virtual void ClearAlternativeServices(const url::SchemeHostPort& origin) = 0;
312 314
313 // Returns all alternative service mappings. 315 // Returns all alternative service mappings.
314 // Returned alternative services may have empty hostnames. 316 // Returned alternative services may have empty hostnames.
315 virtual const AlternativeServiceMap& alternative_service_map() const = 0; 317 virtual const AlternativeServiceMap& alternative_service_map() const = 0;
316 318
317 // Returns all alternative service mappings as human readable strings. 319 // Returns all alternative service mappings as human readable strings.
318 // Empty alternative service hostnames will be printed as such. 320 // Empty alternative service hostnames will be printed as such.
319 virtual std::unique_ptr<base::Value> GetAlternativeServiceInfoAsValue() 321 virtual std::unique_ptr<base::Value> GetAlternativeServiceInfoAsValue()
320 const = 0; 322 const = 0;
321 323
322 // Gets a reference to the SettingsMap stored for a host. 324 // Gets a reference to the SettingsMap stored for a host.
323 // If no settings are stored, returns an empty SettingsMap. 325 // If no settings are stored, returns an empty SettingsMap.
324 virtual const SettingsMap& GetSpdySettings( 326 virtual const SettingsMap& GetSpdySettings(
325 const HostPortPair& host_port_pair) = 0; 327 const url::SchemeHostPort& server) = 0;
326 328
327 // Saves an individual SPDY setting for a host. Returns true if SPDY setting 329 // Saves an individual SPDY setting for a host. Returns true if SPDY setting
328 // is to be persisted. 330 // is to be persisted.
329 virtual bool SetSpdySetting(const HostPortPair& host_port_pair, 331 virtual bool SetSpdySetting(const url::SchemeHostPort& server,
330 SpdySettingsIds id, 332 SpdySettingsIds id,
331 SpdySettingsFlags flags, 333 SpdySettingsFlags flags,
332 uint32_t value) = 0; 334 uint32_t value) = 0;
333 335
334 // Clears all SPDY settings for a host. 336 // Clears all SPDY settings for a host.
335 virtual void ClearSpdySettings(const HostPortPair& host_port_pair) = 0; 337 virtual void ClearSpdySettings(const url::SchemeHostPort& server) = 0;
336 338
337 // Clears all SPDY settings for all hosts. 339 // Clears all SPDY settings for all hosts.
338 virtual void ClearAllSpdySettings() = 0; 340 virtual void ClearAllSpdySettings() = 0;
339 341
340 // Returns all persistent SPDY settings. 342 // Returns all persistent SPDY settings.
341 virtual const SpdySettingsMap& spdy_settings_map() const = 0; 343 virtual const SpdySettingsMap& spdy_settings_map() const = 0;
342 344
343 virtual bool GetSupportsQuic(IPAddress* last_address) const = 0; 345 virtual bool GetSupportsQuic(IPAddress* last_address) const = 0;
344 346
345 virtual void SetSupportsQuic(bool used_quic, 347 virtual void SetSupportsQuic(bool used_quic,
346 const IPAddress& last_address) = 0; 348 const IPAddress& last_address) = 0;
347 349
348 // Sets |stats| for |host_port_pair|. 350 // Sets |stats| for |host_port_pair|.
349 virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, 351 virtual void SetServerNetworkStats(const url::SchemeHostPort& server,
350 ServerNetworkStats stats) = 0; 352 ServerNetworkStats stats) = 0;
351 353
352 virtual const ServerNetworkStats* GetServerNetworkStats( 354 virtual const ServerNetworkStats* GetServerNetworkStats(
353 const HostPortPair& host_port_pair) = 0; 355 const url::SchemeHostPort& server) = 0;
354 356
355 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0; 357 virtual const ServerNetworkStatsMap& server_network_stats_map() const = 0;
356 358
357 // Save QuicServerInfo (in std::string form) for the given |server_id|. 359 // Save QuicServerInfo (in std::string form) for the given |server_id|.
358 // Returns true if the value has changed otherwise it returns false. 360 // Returns true if the value has changed otherwise it returns false.
359 virtual bool SetQuicServerInfo(const QuicServerId& server_id, 361 virtual bool SetQuicServerInfo(const QuicServerId& server_id,
360 const std::string& server_info) = 0; 362 const std::string& server_info) = 0;
361 363
362 // Get QuicServerInfo (in std::string form) for the given |server_id|. 364 // Get QuicServerInfo (in std::string form) for the given |server_id|.
363 virtual const std::string* GetQuicServerInfo( 365 virtual const std::string* GetQuicServerInfo(
364 const QuicServerId& server_id) = 0; 366 const QuicServerId& server_id) = 0;
365 367
366 // Returns all persistent QuicServerInfo objects. 368 // Returns all persistent QuicServerInfo objects.
367 virtual const QuicServerInfoMap& quic_server_info_map() const = 0; 369 virtual const QuicServerInfoMap& quic_server_info_map() const = 0;
368 370
369 // Returns the number of server configs (QuicServerInfo objects) persisted. 371 // Returns the number of server configs (QuicServerInfo objects) persisted.
370 virtual size_t max_server_configs_stored_in_properties() const = 0; 372 virtual size_t max_server_configs_stored_in_properties() const = 0;
371 373
372 // Sets the number of server configs (QuicServerInfo objects) to be persisted. 374 // Sets the number of server configs (QuicServerInfo objects) to be persisted.
373 virtual void SetMaxServerConfigsStoredInProperties( 375 virtual void SetMaxServerConfigsStoredInProperties(
374 size_t max_server_configs_stored_in_properties) = 0; 376 size_t max_server_configs_stored_in_properties) = 0;
375 377
376 private: 378 private:
377 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties); 379 DISALLOW_COPY_AND_ASSIGN(HttpServerProperties);
378 }; 380 };
379 381
380 } // namespace net 382 } // namespace net
381 383
382 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_ 384 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_server_properties_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698