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 <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const ServerNetworkStatsMap& server_network_stats_map() const override; | 110 const ServerNetworkStatsMap& server_network_stats_map() const override; |
111 | 111 |
112 private: | 112 private: |
113 // |spdy_servers_map_| has flattened representation of servers (host, port) | 113 // |spdy_servers_map_| has flattened representation of servers (host, port) |
114 // that either support or not support SPDY protocol. | 114 // that either support or not support SPDY protocol. |
115 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; | 115 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; |
116 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; | 116 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; |
117 typedef std::vector<std::string> CanonicalSufficList; | 117 typedef std::vector<std::string> CanonicalSufficList; |
118 typedef std::set<HostPortPair> Http11ServerHostPortSet; | 118 typedef std::set<HostPortPair> Http11ServerHostPortSet; |
119 | 119 |
120 // Server, port, and AlternateProtocol: an entity that can be broken. (Once | 120 // Broken alternative service with expiration time. |
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.) | |
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 | |
138 HostPortPair server; | |
139 uint16 port; | |
140 AlternateProtocol protocol; | |
141 }; | |
142 // BrokenAlternateProtocolEntry with expiration time. | |
143 struct BrokenAlternateProtocolEntryWithTime { | 121 struct BrokenAlternateProtocolEntryWithTime { |
144 BrokenAlternateProtocolEntryWithTime( | 122 BrokenAlternateProtocolEntryWithTime( |
145 const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry, | 123 const AlternativeService& alternative_service, |
146 base::TimeTicks when) | 124 base::TimeTicks when) |
147 : broken_alternate_protocol_entry(broken_alternate_protocol_entry), | 125 : alternative_service(alternative_service), when(when) {} |
148 when(when) {} | |
149 | 126 |
150 BrokenAlternateProtocolEntry broken_alternate_protocol_entry; | 127 AlternativeService alternative_service; |
151 base::TimeTicks when; | 128 base::TimeTicks when; |
152 }; | 129 }; |
153 // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration | 130 // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration |
154 // time. | 131 // time. |
155 typedef std::deque<BrokenAlternateProtocolEntryWithTime> | 132 typedef std::deque<BrokenAlternateProtocolEntryWithTime> |
156 BrokenAlternateProtocolList; | 133 BrokenAlternateProtocolList; |
157 // Map from (server, alternate protocol and port) to the number of | 134 // Map from (server, alternate protocol and port) to the number of |
158 // times that alternate protocol has been marked broken for that server. | 135 // times that alternate protocol has been marked broken for that server. |
159 typedef std::map<BrokenAlternateProtocolEntry, int> | 136 typedef std::map<AlternativeService, int> BrokenAlternateProtocolMap; |
160 BrokenAlternateProtocolMap; | |
161 | 137 |
162 // Return the iterator for |server|, or for its canonical host, or end. | 138 // Return the iterator for |server|, or for its canonical host, or end. |
163 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( | 139 AlternateProtocolMap::const_iterator GetAlternateProtocolIterator( |
164 const HostPortPair& server); | 140 const HostPortPair& server); |
165 | 141 |
166 // Return the canonical host for |server|, or end if none exists. | 142 // Return the canonical host for |server|, or end if none exists. |
167 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; | 143 CanonicalHostMap::const_iterator GetCanonicalHost(HostPortPair server) const; |
168 | 144 |
169 void RemoveCanonicalHost(const HostPortPair& server); | 145 void RemoveCanonicalHost(const HostPortPair& server); |
170 void ExpireBrokenAlternateProtocolMappings(); | 146 void ExpireBrokenAlternateProtocolMappings(); |
(...skipping 20 matching lines...) Expand all Loading... |
191 double alternate_protocol_probability_threshold_; | 167 double alternate_protocol_probability_threshold_; |
192 | 168 |
193 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; | 169 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; |
194 | 170 |
195 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 171 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
196 }; | 172 }; |
197 | 173 |
198 } // namespace net | 174 } // namespace net |
199 | 175 |
200 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 176 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
OLD | NEW |