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

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

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_server_properties.h ('k') | net/http/http_server_properties_impl.cc » ('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_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 <deque>
8 #include <map> 9 #include <map>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
16 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
17 #include "base/values.h" 18 #include "base/values.h"
(...skipping 18 matching lines...) Expand all
36 // Initializes |spdy_servers_map_| with the servers (host/port) from 37 // Initializes |spdy_servers_map_| with the servers (host/port) from
37 // |spdy_servers| that either support SPDY or not. 38 // |spdy_servers| that either support SPDY or not.
38 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, 39 void InitializeSpdyServers(std::vector<std::string>* spdy_servers,
39 bool support_spdy); 40 bool support_spdy);
40 41
41 void InitializeAlternateProtocolServers( 42 void InitializeAlternateProtocolServers(
42 AlternateProtocolMap* alternate_protocol_servers); 43 AlternateProtocolMap* alternate_protocol_servers);
43 44
44 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); 45 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map);
45 46
46 void InitializeSupportsQuic(SupportsQuicMap* supports_quic_map); 47 void InitializeSupportsQuic(IPAddressNumber* last_address);
47 48
48 void InitializeServerNetworkStats( 49 void InitializeServerNetworkStats(
49 ServerNetworkStatsMap* server_network_stats_map); 50 ServerNetworkStatsMap* server_network_stats_map);
50 51
51 // Get the list of servers (host/port) that support SPDY. The max_size is the 52 // Get the list of servers (host/port) that support SPDY. The max_size is the
52 // number of MRU servers that support SPDY that are to be returned. 53 // number of MRU servers that support SPDY that are to be returned.
53 void GetSpdyServerList(base::ListValue* spdy_server_list, 54 void GetSpdyServerList(base::ListValue* spdy_server_list,
54 size_t max_size) const; 55 size_t max_size) const;
55 56
56 // Returns flattened string representation of the |host_port_pair|. Used by 57 // Returns flattened string representation of the |host_port_pair|. Used by
(...skipping 15 matching lines...) Expand all
72 // ----------------------------- 73 // -----------------------------
73 74
74 base::WeakPtr<HttpServerProperties> GetWeakPtr() override; 75 base::WeakPtr<HttpServerProperties> GetWeakPtr() override;
75 void Clear() override; 76 void Clear() override;
76 bool SupportsRequestPriority(const HostPortPair& server) override; 77 bool SupportsRequestPriority(const HostPortPair& server) override;
77 void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override; 78 void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override;
78 bool RequiresHTTP11(const HostPortPair& server) override; 79 bool RequiresHTTP11(const HostPortPair& server) override;
79 void SetHTTP11Required(const HostPortPair& server) override; 80 void SetHTTP11Required(const HostPortPair& server) override;
80 void MaybeForceHTTP11(const HostPortPair& server, 81 void MaybeForceHTTP11(const HostPortPair& server,
81 SSLConfig* ssl_config) override; 82 SSLConfig* ssl_config) override;
82 bool HasAlternateProtocol(const HostPortPair& server) override;
83 AlternateProtocolInfo GetAlternateProtocol( 83 AlternateProtocolInfo GetAlternateProtocol(
84 const HostPortPair& server) override; 84 const HostPortPair& server) override;
85 void SetAlternateProtocol(const HostPortPair& server, 85 void SetAlternateProtocol(const HostPortPair& server,
86 uint16 alternate_port, 86 uint16 alternate_port,
87 AlternateProtocol alternate_protocol, 87 AlternateProtocol alternate_protocol,
88 double probability) override; 88 double probability) override;
89 void SetBrokenAlternateProtocol(const HostPortPair& server) override; 89 void SetBrokenAlternateProtocol(const HostPortPair& server) override;
90 bool WasAlternateProtocolRecentlyBroken(const HostPortPair& server) override; 90 bool WasAlternateProtocolRecentlyBroken(const HostPortPair& server) override;
91 void ConfirmAlternateProtocol(const HostPortPair& server) override; 91 void ConfirmAlternateProtocol(const HostPortPair& server) override;
92 void ClearAlternateProtocol(const HostPortPair& server) override; 92 void ClearAlternateProtocol(const HostPortPair& server) override;
93 const AlternateProtocolMap& alternate_protocol_map() const override; 93 const AlternateProtocolMap& alternate_protocol_map() const override;
94 void SetAlternateProtocolProbabilityThreshold(double threshold) override; 94 void SetAlternateProtocolProbabilityThreshold(double threshold) override;
95 const SettingsMap& GetSpdySettings( 95 const SettingsMap& GetSpdySettings(
96 const HostPortPair& host_port_pair) override; 96 const HostPortPair& host_port_pair) override;
97 bool SetSpdySetting(const HostPortPair& host_port_pair, 97 bool SetSpdySetting(const HostPortPair& host_port_pair,
98 SpdySettingsIds id, 98 SpdySettingsIds id,
99 SpdySettingsFlags flags, 99 SpdySettingsFlags flags,
100 uint32 value) override; 100 uint32 value) override;
101 void ClearSpdySettings(const HostPortPair& host_port_pair) override; 101 void ClearSpdySettings(const HostPortPair& host_port_pair) override;
102 void ClearAllSpdySettings() override; 102 void ClearAllSpdySettings() override;
103 const SpdySettingsMap& spdy_settings_map() const override; 103 const SpdySettingsMap& spdy_settings_map() const override;
104 SupportsQuic GetSupportsQuic( 104 bool GetSupportsQuic(IPAddressNumber* last_address) const override;
105 const HostPortPair& host_port_pair) const override; 105 void SetSupportsQuic(bool used_quic, const IPAddressNumber& address) override;
106 void SetSupportsQuic(const HostPortPair& host_port_pair,
107 bool used_quic,
108 const std::string& address) override;
109 const SupportsQuicMap& supports_quic_map() const override;
110 void SetServerNetworkStats(const HostPortPair& host_port_pair, 106 void SetServerNetworkStats(const HostPortPair& host_port_pair,
111 ServerNetworkStats stats) override; 107 ServerNetworkStats stats) override;
112 const ServerNetworkStats* GetServerNetworkStats( 108 const ServerNetworkStats* GetServerNetworkStats(
113 const HostPortPair& host_port_pair) override; 109 const HostPortPair& host_port_pair) override;
114 const ServerNetworkStatsMap& server_network_stats_map() const override; 110 const ServerNetworkStatsMap& server_network_stats_map() const override;
115 111
116 private: 112 private:
117 // |spdy_servers_map_| has flattened representation of servers (host, port) 113 // |spdy_servers_map_| has flattened representation of servers (host, port)
118 // that either support or not support SPDY protocol. 114 // that either support or not support SPDY protocol.
119 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; 115 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap;
120 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; 116 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
121 typedef std::vector<std::string> CanonicalSufficList; 117 typedef std::vector<std::string> CanonicalSufficList;
122 typedef std::set<HostPortPair> Http11ServerHostPortSet; 118 typedef std::set<HostPortPair> Http11ServerHostPortSet;
123 // List of broken host:ports and the times when they can be expired. 119
120 // Server, port, and AlternateProtocol: an entity that can be broken. (Once
121 // we use AlternativeService, the same AltSvc can be broken for one server but
122 // not for another depending on what certificate it can offer.)
124 struct BrokenAlternateProtocolEntry { 123 struct BrokenAlternateProtocolEntry {
124 BrokenAlternateProtocolEntry(const BrokenAlternateProtocolEntry&) = default;
125 BrokenAlternateProtocolEntry(const HostPortPair& server,
126 uint16 port,
127 AlternateProtocol protocol)
128 : server(server), port(port), protocol(protocol) {}
129
130 bool operator<(const BrokenAlternateProtocolEntry& other) const {
131 if (!server.Equals(other.server))
132 return server < other.server;
133 if (port != other.port)
134 return port < other.port;
135 return protocol < other.protocol;
136 }
137
125 HostPortPair server; 138 HostPortPair server;
139 uint16 port;
140 AlternateProtocol protocol;
141 };
142 // BrokenAlternateProtocolEntry with expiration time.
143 struct BrokenAlternateProtocolEntryWithTime {
144 BrokenAlternateProtocolEntryWithTime(
145 const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry,
146 base::TimeTicks when)
147 : broken_alternate_protocol_entry(broken_alternate_protocol_entry),
148 when(when) {}
149
150 BrokenAlternateProtocolEntry broken_alternate_protocol_entry;
126 base::TimeTicks when; 151 base::TimeTicks when;
127 }; 152 };
128 typedef std::list<BrokenAlternateProtocolEntry> 153 // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration
154 // time.
155 typedef std::deque<BrokenAlternateProtocolEntryWithTime>
129 BrokenAlternateProtocolList; 156 BrokenAlternateProtocolList;
130 // Map from host:port to the number of times alternate protocol has 157 // Map from (server, alternate protocol and port) to the number of
131 // been marked broken. 158 // times that alternate protocol has been marked broken for that server.
132 typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap; 159 typedef std::map<BrokenAlternateProtocolEntry, int>
160 BrokenAlternateProtocolMap;
133 161
134 // Return the iterator for |server|, or for its canonical host, or end. 162 // Return the iterator for |server|, or for its canonical host, or end.
135 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( 163 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator(
136 const HostPortPair& server); 164 const HostPortPair& server);
137 165
138 // Return the canonical host for |server|, or end if none exists. 166 // Return the canonical host for |server|, or end if none exists.
139 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; 167 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const;
140 168
141 void RemoveCanonicalHost(const HostPortPair& server); 169 void RemoveCanonicalHost(const HostPortPair& server);
142 void ExpireBrokenAlternateProtocolMappings(); 170 void ExpireBrokenAlternateProtocolMappings();
143 void ScheduleBrokenAlternateProtocolMappingsExpiration(); 171 void ScheduleBrokenAlternateProtocolMappingsExpiration();
144 172
145 SpdyServerHostPortMap spdy_servers_map_; 173 SpdyServerHostPortMap spdy_servers_map_;
146 Http11ServerHostPortSet http11_servers_; 174 Http11ServerHostPortSet http11_servers_;
147 175
148 AlternateProtocolMap alternate_protocol_map_; 176 AlternateProtocolMap alternate_protocol_map_;
149 BrokenAlternateProtocolList broken_alternate_protocol_list_; 177 BrokenAlternateProtocolList broken_alternate_protocol_list_;
150 BrokenAlternateProtocolMap broken_alternate_protocol_map_; 178 BrokenAlternateProtocolMap broken_alternate_protocol_map_;
151 179
180 IPAddressNumber last_quic_address_;
152 SpdySettingsMap spdy_settings_map_; 181 SpdySettingsMap spdy_settings_map_;
153 SupportsQuicMap supports_quic_map_;
154 ServerNetworkStatsMap server_network_stats_map_; 182 ServerNetworkStatsMap server_network_stats_map_;
155 // Contains a map of servers which could share the same alternate protocol. 183 // Contains a map of servers which could share the same alternate protocol.
156 // Map from a Canonical host/port (host is some postfix of host names) to an 184 // Map from a Canonical host/port (host is some postfix of host names) to an
157 // actual origin, which has a plausible alternate protocol mapping. 185 // actual origin, which has a plausible alternate protocol mapping.
158 CanonicalHostMap canonical_host_to_origin_map_; 186 CanonicalHostMap canonical_host_to_origin_map_;
159 // Contains list of suffixes (for exmaple ".c.youtube.com", 187 // Contains list of suffixes (for exmaple ".c.youtube.com",
160 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames. 188 // ".googlevideo.com", ".googleusercontent.com") of canonical hostnames.
161 CanonicalSufficList canonical_suffixes_; 189 CanonicalSufficList canonical_suffixes_;
162 190
163 double alternate_protocol_probability_threshold_; 191 double alternate_protocol_probability_threshold_;
164 192
165 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; 193 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
166 194
167 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); 195 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
168 }; 196 };
169 197
170 } // namespace net 198 } // namespace net
171 199
172 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ 200 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
OLDNEW
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/http/http_server_properties_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698