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

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

Issue 2932953002: Persist broken and recently-broken alt-svcs to prefs in HttpServerPropertiesManager (Closed)
Patch Set: Removed BrokenAlternativeServices::Clear() so it can be added in a separate CL 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_IMPL_H_ 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
20 #include "base/time/default_tick_clock.h"
21 #include "base/values.h" 20 #include "base/values.h"
22 #include "net/base/host_port_pair.h" 21 #include "net/base/host_port_pair.h"
23 #include "net/base/ip_address.h" 22 #include "net/base/ip_address.h"
24 #include "net/base/linked_hash_map.h" 23 #include "net/base/linked_hash_map.h"
25 #include "net/base/net_export.h" 24 #include "net/base/net_export.h"
26 #include "net/http/broken_alternative_services.h" 25 #include "net/http/broken_alternative_services.h"
27 #include "net/http/http_server_properties.h" 26 #include "net/http/http_server_properties.h"
28 27
29 namespace base { 28 namespace base {
30 class ListValue; 29 class ListValue;
30 class TickClock;
31 } 31 }
32 32
33 namespace net { 33 namespace net {
34 34
35 // The implementation for setting/retrieving the HTTP server properties. 35 // The implementation for setting/retrieving the HTTP server properties.
36 class NET_EXPORT HttpServerPropertiesImpl 36 class NET_EXPORT HttpServerPropertiesImpl
37 : public HttpServerProperties, 37 : public HttpServerProperties,
38 public BrokenAlternativeServices::Delegate { 38 public BrokenAlternativeServices::Delegate {
39 public: 39 public:
40 // |clock| is used for setting expiration times and scheduling the
41 // expiration of broken alternative services. It must not be null.
42 HttpServerPropertiesImpl(base::TickClock* clock);
Zhongyi Shi 2017/06/16 04:17:09 nit: explicit
wangyix1 2017/06/16 18:41:15 Done.
43
44 // Default clock will be used.
40 HttpServerPropertiesImpl(); 45 HttpServerPropertiesImpl();
41 explicit HttpServerPropertiesImpl( 46
42 base::TickClock* broken_alternative_services_clock);
43 ~HttpServerPropertiesImpl() override; 47 ~HttpServerPropertiesImpl() override;
44 48
45 // Sets |spdy_servers_map_| with the servers (host/port) from 49 // Sets |spdy_servers_map_| with the servers (host/port) from
46 // |spdy_servers| that either support SPDY or not. 50 // |spdy_servers| that either support SPDY or not.
47 void SetSpdyServers(std::vector<std::string>* spdy_servers, 51 void SetSpdyServers(std::vector<std::string>* spdy_servers,
48 bool support_spdy); 52 bool support_spdy);
49 53
50 void SetAlternativeServiceServers( 54 void SetAlternativeServiceServers(
51 AlternativeServiceMap* alternate_protocol_servers); 55 AlternativeServiceMap* alternate_protocol_servers);
52 56
53 void SetSupportsQuic(IPAddress* last_address); 57 void SetSupportsQuic(IPAddress* last_address);
54 58
55 void SetServerNetworkStats(ServerNetworkStatsMap* server_network_stats_map); 59 void SetServerNetworkStats(ServerNetworkStatsMap* server_network_stats_map);
56 60
57 void SetQuicServerInfoMap(QuicServerInfoMap* quic_server_info_map); 61 void SetQuicServerInfoMap(QuicServerInfoMap* quic_server_info_map);
58 62
59 // Get the list of servers (host/port) that support SPDY. The max_size is the 63 // Get the list of servers (host/port) that support SPDY. The max_size is the
60 // number of MRU servers that support SPDY that are to be returned. 64 // number of MRU servers that support SPDY that are to be returned.
61 void GetSpdyServerList(base::ListValue* spdy_server_list, 65 void GetSpdyServerList(base::ListValue* spdy_server_list,
62 size_t max_size) const; 66 size_t max_size) const;
63 67
68 void SetBrokenAndRecentlyBrokenAlternativeServices(
69 std::unique_ptr<BrokenAlternativeServiceList>
70 broken_alternative_service_list,
71 std::unique_ptr<RecentlyBrokenAlternativeServices>
72 recently_broken_alternative_services);
Zhongyi Shi 2017/06/16 04:17:09 Does the raw pointers work? Usually pass by unique
wangyix1 2017/06/16 18:41:15 unique_ptrs are used since these params are simply
73
74 const BrokenAlternativeServiceList& broken_alternative_service_list() const;
75
76 const RecentlyBrokenAlternativeServices&
77 recently_broken_alternative_services() const;
78
64 // Returns flattened string representation of the |host_port_pair|. Used by 79 // Returns flattened string representation of the |host_port_pair|. Used by
65 // unittests. 80 // unittests.
66 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair); 81 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair);
67 82
68 // Returns the canonical host suffix for |host|, or nullptr if none 83 // Returns the canonical host suffix for |host|, or nullptr if none
69 // exists. 84 // exists.
70 const std::string* GetCanonicalSuffix(const std::string& host) const; 85 const std::string* GetCanonicalSuffix(const std::string& host) const;
71 86
72 // ----------------------------- 87 // -----------------------------
73 // HttpServerProperties methods: 88 // HttpServerProperties methods:
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( 155 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator(
141 const url::SchemeHostPort& server); 156 const url::SchemeHostPort& server);
142 157
143 // Return the canonical host for |server|, or end if none exists. 158 // Return the canonical host for |server|, or end if none exists.
144 CanonicalHostMap::const_iterator GetCanonicalHost( 159 CanonicalHostMap::const_iterator GetCanonicalHost(
145 const url::SchemeHostPort& server) const; 160 const url::SchemeHostPort& server) const;
146 161
147 // Remove the cononical host for |server|. 162 // Remove the cononical host for |server|.
148 void RemoveCanonicalHost(const url::SchemeHostPort& server); 163 void RemoveCanonicalHost(const url::SchemeHostPort& server);
149 164
150 base::DefaultTickClock broken_alternative_services_clock_; 165 base::DefaultTickClock default_clock_;
151 BrokenAlternativeServices broken_alternative_services_;
152 166
153 SpdyServersMap spdy_servers_map_; 167 SpdyServersMap spdy_servers_map_;
154 Http11ServerHostPortSet http11_servers_; 168 Http11ServerHostPortSet http11_servers_;
155 169
156 AlternativeServiceMap alternative_service_map_; 170 AlternativeServiceMap alternative_service_map_;
157 171
172 BrokenAlternativeServices broken_alternative_services_;
173
158 IPAddress last_quic_address_; 174 IPAddress last_quic_address_;
159 ServerNetworkStatsMap server_network_stats_map_; 175 ServerNetworkStatsMap server_network_stats_map_;
160 // Contains a map of servers which could share the same alternate protocol. 176 // Contains a map of servers which could share the same alternate protocol.
161 // Map from a Canonical scheme/host/port (host is some postfix of host names) 177 // Map from a Canonical scheme/host/port (host is some postfix of host names)
162 // to an actual origin, which has a plausible alternate protocol mapping. 178 // to an actual origin, which has a plausible alternate protocol mapping.
163 CanonicalHostMap canonical_host_to_origin_map_; 179 CanonicalHostMap canonical_host_to_origin_map_;
164 // Contains list of suffixes (for exmaple ".c.youtube.com", 180 // Contains list of suffixes (for exmaple ".c.youtube.com",
165 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames. 181 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames.
166 CanonicalSufficList canonical_suffixes_; 182 CanonicalSufficList canonical_suffixes_;
167 183
168 QuicServerInfoMap quic_server_info_map_; 184 QuicServerInfoMap quic_server_info_map_;
169 size_t max_server_configs_stored_in_properties_; 185 size_t max_server_configs_stored_in_properties_;
170 186
171 THREAD_CHECKER(thread_checker_); 187 THREAD_CHECKER(thread_checker_);
172 188
173 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 189 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
174 }; 190 };
175 191
176 } // namespace net 192 } // namespace net
177 193
178 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 194 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698