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_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" | 20 #include "base/time/default_tick_clock.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "net/base/host_port_pair.h" | 22 #include "net/base/host_port_pair.h" |
23 #include "net/base/ip_address.h" | 23 #include "net/base/ip_address.h" |
24 #include "net/base/linked_hash_map.h" | 24 #include "net/base/linked_hash_map.h" |
25 #include "net/base/net_export.h" | 25 #include "net/base/net_export.h" |
26 #include "net/http/broken_alternative_services.h" | 26 #include "net/http/broken_alternative_services.h" |
27 #include "net/http/http_server_properties.h" | 27 #include "net/http/http_server_properties.h" |
28 | 28 |
| 29 namespace base { |
| 30 class TickClock; |
| 31 } |
| 32 |
29 namespace net { | 33 namespace net { |
30 | 34 |
31 // The implementation for setting/retrieving the HTTP server properties. | 35 // The implementation for setting/retrieving the HTTP server properties. |
32 class NET_EXPORT HttpServerPropertiesImpl | 36 class NET_EXPORT HttpServerPropertiesImpl |
33 : public HttpServerProperties, | 37 : public HttpServerProperties, |
34 public BrokenAlternativeServices::Delegate { | 38 public BrokenAlternativeServices::Delegate { |
35 public: | 39 public: |
| 40 // |clock| is used for setting expiration times and scheduling the |
| 41 // expiration of broken alternative services. If null, default clock will be |
| 42 // used. |
| 43 explicit HttpServerPropertiesImpl(base::TickClock* clock); |
| 44 |
| 45 // Default clock will be used. |
36 HttpServerPropertiesImpl(); | 46 HttpServerPropertiesImpl(); |
37 explicit HttpServerPropertiesImpl( | 47 |
38 base::TickClock* broken_alternative_services_clock); | |
39 ~HttpServerPropertiesImpl() override; | 48 ~HttpServerPropertiesImpl() override; |
40 | 49 |
41 // Sets |spdy_servers_map_| with the servers (host/port) from | 50 // Sets |spdy_servers_map_| with the servers (host/port) from |
42 // |spdy_servers| that either support SPDY or not. | 51 // |spdy_servers| that either support SPDY or not. |
43 void SetSpdyServers(std::unique_ptr<SpdyServersMap> spdy_servers_map); | 52 void SetSpdyServers(std::unique_ptr<SpdyServersMap> spdy_servers_map); |
44 | 53 |
45 void SetAlternativeServiceServers( | 54 void SetAlternativeServiceServers( |
46 std::unique_ptr<AlternativeServiceMap> alternate_protocol_servers); | 55 std::unique_ptr<AlternativeServiceMap> alternate_protocol_servers); |
47 | 56 |
48 void SetSupportsQuic(const IPAddress& last_address); | 57 void SetSupportsQuic(const IPAddress& last_address); |
49 | 58 |
50 void SetServerNetworkStats( | 59 void SetServerNetworkStats( |
51 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map); | 60 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map); |
52 | 61 |
53 void SetQuicServerInfoMap( | 62 void SetQuicServerInfoMap( |
54 std::unique_ptr<QuicServerInfoMap> quic_server_info_map); | 63 std::unique_ptr<QuicServerInfoMap> quic_server_info_map); |
55 | 64 |
56 // Get the list of servers (host/port) that support SPDY. The max_size is the | 65 // Get the list of servers (host/port) that support SPDY. The max_size is the |
57 // number of MRU servers that support SPDY that are to be returned. | 66 // number of MRU servers that support SPDY that are to be returned. |
58 void GetSpdyServerList(std::vector<std::string>* spdy_servers, | 67 void GetSpdyServerList(std::vector<std::string>* spdy_servers, |
59 size_t max_size) const; | 68 size_t max_size) const; |
60 | 69 |
| 70 void SetBrokenAndRecentlyBrokenAlternativeServices( |
| 71 std::unique_ptr<BrokenAlternativeServiceList> |
| 72 broken_alternative_service_list, |
| 73 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 74 recently_broken_alternative_services); |
| 75 |
| 76 const BrokenAlternativeServiceList& broken_alternative_service_list() const; |
| 77 |
| 78 const RecentlyBrokenAlternativeServices& |
| 79 recently_broken_alternative_services() const; |
| 80 |
61 // Returns flattened string representation of the |host_port_pair|. Used by | 81 // Returns flattened string representation of the |host_port_pair|. Used by |
62 // unittests. | 82 // unittests. |
63 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair); | 83 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair); |
64 | 84 |
65 // Returns the canonical host suffix for |host|, or nullptr if none | 85 // Returns the canonical host suffix for |host|, or nullptr if none |
66 // exists. | 86 // exists. |
67 const std::string* GetCanonicalSuffix(const std::string& host) const; | 87 const std::string* GetCanonicalSuffix(const std::string& host) const; |
68 | 88 |
69 // ----------------------------- | 89 // ----------------------------- |
70 // HttpServerProperties methods: | 90 // HttpServerProperties methods: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( | 154 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( |
135 const url::SchemeHostPort& server); | 155 const url::SchemeHostPort& server); |
136 | 156 |
137 // Return the canonical host for |server|, or end if none exists. | 157 // Return the canonical host for |server|, or end if none exists. |
138 CanonicalHostMap::const_iterator GetCanonicalHost( | 158 CanonicalHostMap::const_iterator GetCanonicalHost( |
139 const url::SchemeHostPort& server) const; | 159 const url::SchemeHostPort& server) const; |
140 | 160 |
141 // Remove the cononical host for |server|. | 161 // Remove the cononical host for |server|. |
142 void RemoveCanonicalHost(const url::SchemeHostPort& server); | 162 void RemoveCanonicalHost(const url::SchemeHostPort& server); |
143 | 163 |
144 base::DefaultTickClock broken_alternative_services_clock_; | 164 base::DefaultTickClock default_clock_; |
145 BrokenAlternativeServices broken_alternative_services_; | |
146 | 165 |
147 SpdyServersMap spdy_servers_map_; | 166 SpdyServersMap spdy_servers_map_; |
148 Http11ServerHostPortSet http11_servers_; | 167 Http11ServerHostPortSet http11_servers_; |
149 | 168 |
150 AlternativeServiceMap alternative_service_map_; | 169 AlternativeServiceMap alternative_service_map_; |
151 | 170 |
| 171 BrokenAlternativeServices broken_alternative_services_; |
| 172 |
152 IPAddress last_quic_address_; | 173 IPAddress last_quic_address_; |
153 ServerNetworkStatsMap server_network_stats_map_; | 174 ServerNetworkStatsMap server_network_stats_map_; |
154 // Contains a map of servers which could share the same alternate protocol. | 175 // Contains a map of servers which could share the same alternate protocol. |
155 // Map from a Canonical scheme/host/port (host is some postfix of host names) | 176 // Map from a Canonical scheme/host/port (host is some postfix of host names) |
156 // to an actual origin, which has a plausible alternate protocol mapping. | 177 // to an actual origin, which has a plausible alternate protocol mapping. |
157 CanonicalHostMap canonical_host_to_origin_map_; | 178 CanonicalHostMap canonical_host_to_origin_map_; |
158 // Contains list of suffixes (for exmaple ".c.youtube.com", | 179 // Contains list of suffixes (for exmaple ".c.youtube.com", |
159 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames. | 180 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames. |
160 CanonicalSufficList canonical_suffixes_; | 181 CanonicalSufficList canonical_suffixes_; |
161 | 182 |
162 QuicServerInfoMap quic_server_info_map_; | 183 QuicServerInfoMap quic_server_info_map_; |
163 size_t max_server_configs_stored_in_properties_; | 184 size_t max_server_configs_stored_in_properties_; |
164 | 185 |
165 THREAD_CHECKER(thread_checker_); | 186 THREAD_CHECKER(thread_checker_); |
166 | 187 |
167 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 188 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
168 }; | 189 }; |
169 | 190 |
170 } // namespace net | 191 } // namespace net |
171 | 192 |
172 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 193 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
OLD | NEW |