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 ListValue; | |
31 } | |
32 | |
33 namespace net { | 29 namespace net { |
34 | 30 |
35 // The implementation for setting/retrieving the HTTP server properties. | 31 // The implementation for setting/retrieving the HTTP server properties. |
36 class NET_EXPORT HttpServerPropertiesImpl | 32 class NET_EXPORT HttpServerPropertiesImpl |
37 : public HttpServerProperties, | 33 : public HttpServerProperties, |
38 public BrokenAlternativeServices::Delegate { | 34 public BrokenAlternativeServices::Delegate { |
39 public: | 35 public: |
40 HttpServerPropertiesImpl(); | 36 HttpServerPropertiesImpl(); |
41 explicit HttpServerPropertiesImpl( | 37 explicit HttpServerPropertiesImpl( |
42 base::TickClock* broken_alternative_services_clock); | 38 base::TickClock* broken_alternative_services_clock); |
43 ~HttpServerPropertiesImpl() override; | 39 ~HttpServerPropertiesImpl() override; |
44 | 40 |
45 // Sets |spdy_servers_map_| with the servers (host/port) from | 41 // Sets |spdy_servers_map_| with the servers (host/port) from |
46 // |spdy_servers| that either support SPDY or not. | 42 // |spdy_servers| that either support SPDY or not. |
47 void SetSpdyServers(std::vector<std::string>* spdy_servers, | 43 void SetSpdyServers(std::unique_ptr<SpdyServersMap> spdy_servers_map); |
48 bool support_spdy); | |
49 | 44 |
50 void SetAlternativeServiceServers( | 45 void SetAlternativeServiceServers( |
51 AlternativeServiceMap* alternate_protocol_servers); | 46 std::unique_ptr<AlternativeServiceMap> alternate_protocol_servers); |
52 | 47 |
53 void SetSupportsQuic(IPAddress* last_address); | 48 void SetSupportsQuic(const IPAddress& last_address); |
54 | 49 |
55 void SetServerNetworkStats(ServerNetworkStatsMap* server_network_stats_map); | 50 void SetServerNetworkStats( |
| 51 std::unique_ptr<ServerNetworkStatsMap> server_network_stats_map); |
56 | 52 |
57 void SetQuicServerInfoMap(QuicServerInfoMap* quic_server_info_map); | 53 void SetQuicServerInfoMap( |
| 54 std::unique_ptr<QuicServerInfoMap> quic_server_info_map); |
58 | 55 |
59 // Get the list of servers (host/port) that support SPDY. The max_size is the | 56 // 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. | 57 // number of MRU servers that support SPDY that are to be returned. |
61 void GetSpdyServerList(base::ListValue* spdy_server_list, | 58 void GetSpdyServerList(std::vector<std::string>* spdy_servers, |
62 size_t max_size) const; | 59 size_t max_size) const; |
63 | 60 |
64 // Returns flattened string representation of the |host_port_pair|. Used by | 61 // Returns flattened string representation of the |host_port_pair|. Used by |
65 // unittests. | 62 // unittests. |
66 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair); | 63 static std::string GetFlattenedSpdyServer(const HostPortPair& host_port_pair); |
67 | 64 |
68 // Returns the canonical host suffix for |host|, or nullptr if none | 65 // Returns the canonical host suffix for |host|, or nullptr if none |
69 // exists. | 66 // exists. |
70 const std::string* GetCanonicalSuffix(const std::string& host) const; | 67 const std::string* GetCanonicalSuffix(const std::string& host) const; |
71 | 68 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 119 |
123 // BrokenAlternativeServices::Delegate method. | 120 // BrokenAlternativeServices::Delegate method. |
124 void OnExpireBrokenAlternativeService( | 121 void OnExpireBrokenAlternativeService( |
125 const AlternativeService& expired_alternative_service) override; | 122 const AlternativeService& expired_alternative_service) override; |
126 | 123 |
127 private: | 124 private: |
128 // TODO (wangyix): modify HttpServerPropertiesImpl unit tests so this | 125 // TODO (wangyix): modify HttpServerPropertiesImpl unit tests so this |
129 // friendness is no longer required. | 126 // friendness is no longer required. |
130 friend class HttpServerPropertiesImplPeer; | 127 friend class HttpServerPropertiesImplPeer; |
131 | 128 |
132 // |spdy_servers_map_| has flattened representation of servers | |
133 // (scheme, host, port) that either support or not support SPDY protocol. | |
134 typedef base::MRUCache<std::string, bool> SpdyServersMap; | |
135 typedef std::map<url::SchemeHostPort, url::SchemeHostPort> CanonicalHostMap; | 129 typedef std::map<url::SchemeHostPort, url::SchemeHostPort> CanonicalHostMap; |
136 typedef std::vector<std::string> CanonicalSufficList; | 130 typedef std::vector<std::string> CanonicalSufficList; |
137 typedef std::set<HostPortPair> Http11ServerHostPortSet; | 131 typedef std::set<HostPortPair> Http11ServerHostPortSet; |
138 | 132 |
139 // Return the iterator for |server|, or for its canonical host, or end. | 133 // Return the iterator for |server|, or for its canonical host, or end. |
140 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( | 134 AlternativeServiceMap::const_iterator GetAlternateProtocolIterator( |
141 const url::SchemeHostPort& server); | 135 const url::SchemeHostPort& server); |
142 | 136 |
143 // Return the canonical host for |server|, or end if none exists. | 137 // Return the canonical host for |server|, or end if none exists. |
144 CanonicalHostMap::const_iterator GetCanonicalHost( | 138 CanonicalHostMap::const_iterator GetCanonicalHost( |
(...skipping 24 matching lines...) Expand all Loading... |
169 size_t max_server_configs_stored_in_properties_; | 163 size_t max_server_configs_stored_in_properties_; |
170 | 164 |
171 THREAD_CHECKER(thread_checker_); | 165 THREAD_CHECKER(thread_checker_); |
172 | 166 |
173 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 167 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
174 }; | 168 }; |
175 | 169 |
176 } // namespace net | 170 } // namespace net |
177 | 171 |
178 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 172 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
OLD | NEW |