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 #include "net/http/http_server_properties_impl.h" | 5 #include "net/http/http_server_properties_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), | 39 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), |
40 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist), | 40 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist), |
41 weak_ptr_factory_(this) { | 41 weak_ptr_factory_(this) { |
42 canonical_suffixes_.push_back(".ggpht.com"); | 42 canonical_suffixes_.push_back(".ggpht.com"); |
43 canonical_suffixes_.push_back(".c.youtube.com"); | 43 canonical_suffixes_.push_back(".c.youtube.com"); |
44 canonical_suffixes_.push_back(".googlevideo.com"); | 44 canonical_suffixes_.push_back(".googlevideo.com"); |
45 canonical_suffixes_.push_back(".googleusercontent.com"); | 45 canonical_suffixes_.push_back(".googleusercontent.com"); |
46 } | 46 } |
47 | 47 |
48 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 48 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
| 49 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
49 } | 50 } |
50 | 51 |
51 void HttpServerPropertiesImpl::SetSpdyServers( | 52 void HttpServerPropertiesImpl::SetSpdyServers( |
52 std::vector<std::string>* spdy_servers, | 53 std::vector<std::string>* spdy_servers, |
53 bool support_spdy) { | 54 bool support_spdy) { |
54 DCHECK(CalledOnValidThread()); | 55 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
55 if (!spdy_servers) | 56 if (!spdy_servers) |
56 return; | 57 return; |
57 | 58 |
58 // Add the entries from persisted data. | 59 // Add the entries from persisted data. |
59 SpdyServersMap spdy_servers_map(SpdyServersMap::NO_AUTO_EVICT); | 60 SpdyServersMap spdy_servers_map(SpdyServersMap::NO_AUTO_EVICT); |
60 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); | 61 for (std::vector<std::string>::reverse_iterator it = spdy_servers->rbegin(); |
61 it != spdy_servers->rend(); ++it) { | 62 it != spdy_servers->rend(); ++it) { |
62 spdy_servers_map.Put(*it, support_spdy); | 63 spdy_servers_map.Put(*it, support_spdy); |
63 } | 64 } |
64 | 65 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 it != temp_map.rend(); ++it) { | 183 it != temp_map.rend(); ++it) { |
183 if (quic_server_info_map_.Get(it->first) == quic_server_info_map_.end()) { | 184 if (quic_server_info_map_.Get(it->first) == quic_server_info_map_.end()) { |
184 quic_server_info_map_.Put(it->first, it->second); | 185 quic_server_info_map_.Put(it->first, it->second); |
185 } | 186 } |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 void HttpServerPropertiesImpl::GetSpdyServerList( | 190 void HttpServerPropertiesImpl::GetSpdyServerList( |
190 base::ListValue* spdy_server_list, | 191 base::ListValue* spdy_server_list, |
191 size_t max_size) const { | 192 size_t max_size) const { |
192 DCHECK(CalledOnValidThread()); | 193 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
193 DCHECK(spdy_server_list); | 194 DCHECK(spdy_server_list); |
194 spdy_server_list->Clear(); | 195 spdy_server_list->Clear(); |
195 size_t count = 0; | 196 size_t count = 0; |
196 // Get the list of servers (scheme/host/port) that support SPDY. | 197 // Get the list of servers (scheme/host/port) that support SPDY. |
197 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); | 198 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); |
198 it != spdy_servers_map_.end() && count < max_size; ++it) { | 199 it != spdy_servers_map_.end() && count < max_size; ++it) { |
199 const std::string spdy_server = it->first; | 200 const std::string spdy_server = it->first; |
200 if (it->second) { | 201 if (it->second) { |
201 spdy_server_list->AppendString(spdy_server); | 202 spdy_server_list->AppendString(spdy_server); |
202 ++count; | 203 ++count; |
203 } | 204 } |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 void HttpServerPropertiesImpl::Clear() { | 208 void HttpServerPropertiesImpl::Clear() { |
208 DCHECK(CalledOnValidThread()); | 209 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
209 spdy_servers_map_.Clear(); | 210 spdy_servers_map_.Clear(); |
210 alternative_service_map_.Clear(); | 211 alternative_service_map_.Clear(); |
211 canonical_host_to_origin_map_.clear(); | 212 canonical_host_to_origin_map_.clear(); |
212 last_quic_address_ = IPAddress(); | 213 last_quic_address_ = IPAddress(); |
213 server_network_stats_map_.Clear(); | 214 server_network_stats_map_.Clear(); |
214 quic_server_info_map_.Clear(); | 215 quic_server_info_map_.Clear(); |
215 } | 216 } |
216 | 217 |
217 bool HttpServerPropertiesImpl::SupportsRequestPriority( | 218 bool HttpServerPropertiesImpl::SupportsRequestPriority( |
218 const url::SchemeHostPort& server) { | 219 const url::SchemeHostPort& server) { |
219 DCHECK(CalledOnValidThread()); | 220 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
220 if (server.host().empty()) | 221 if (server.host().empty()) |
221 return false; | 222 return false; |
222 | 223 |
223 if (GetSupportsSpdy(server)) | 224 if (GetSupportsSpdy(server)) |
224 return true; | 225 return true; |
225 const AlternativeServiceInfoVector alternative_service_info_vector = | 226 const AlternativeServiceInfoVector alternative_service_info_vector = |
226 GetAlternativeServiceInfos(server); | 227 GetAlternativeServiceInfos(server); |
227 for (const AlternativeServiceInfo& alternative_service_info : | 228 for (const AlternativeServiceInfo& alternative_service_info : |
228 alternative_service_info_vector) { | 229 alternative_service_info_vector) { |
229 if (alternative_service_info.alternative_service.protocol == kProtoQUIC) { | 230 if (alternative_service_info.alternative_service.protocol == kProtoQUIC) { |
230 return true; | 231 return true; |
231 } | 232 } |
232 } | 233 } |
233 return false; | 234 return false; |
234 } | 235 } |
235 | 236 |
236 bool HttpServerPropertiesImpl::GetSupportsSpdy( | 237 bool HttpServerPropertiesImpl::GetSupportsSpdy( |
237 const url::SchemeHostPort& server) { | 238 const url::SchemeHostPort& server) { |
238 DCHECK(CalledOnValidThread()); | 239 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
239 if (server.host().empty()) | 240 if (server.host().empty()) |
240 return false; | 241 return false; |
241 | 242 |
242 SpdyServersMap::iterator spdy_server = | 243 SpdyServersMap::iterator spdy_server = |
243 spdy_servers_map_.Get(server.Serialize()); | 244 spdy_servers_map_.Get(server.Serialize()); |
244 return spdy_server != spdy_servers_map_.end() && spdy_server->second; | 245 return spdy_server != spdy_servers_map_.end() && spdy_server->second; |
245 } | 246 } |
246 | 247 |
247 void HttpServerPropertiesImpl::SetSupportsSpdy( | 248 void HttpServerPropertiesImpl::SetSupportsSpdy( |
248 const url::SchemeHostPort& server, | 249 const url::SchemeHostPort& server, |
249 bool support_spdy) { | 250 bool support_spdy) { |
250 DCHECK(CalledOnValidThread()); | 251 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
251 if (server.host().empty()) | 252 if (server.host().empty()) |
252 return; | 253 return; |
253 | 254 |
254 SpdyServersMap::iterator spdy_server = | 255 SpdyServersMap::iterator spdy_server = |
255 spdy_servers_map_.Get(server.Serialize()); | 256 spdy_servers_map_.Get(server.Serialize()); |
256 if ((spdy_server != spdy_servers_map_.end()) && | 257 if ((spdy_server != spdy_servers_map_.end()) && |
257 (spdy_server->second == support_spdy)) { | 258 (spdy_server->second == support_spdy)) { |
258 return; | 259 return; |
259 } | 260 } |
260 // Cache the data. | 261 // Cache the data. |
261 spdy_servers_map_.Put(server.Serialize(), support_spdy); | 262 spdy_servers_map_.Put(server.Serialize(), support_spdy); |
262 } | 263 } |
263 | 264 |
264 bool HttpServerPropertiesImpl::RequiresHTTP11( | 265 bool HttpServerPropertiesImpl::RequiresHTTP11( |
265 const HostPortPair& host_port_pair) { | 266 const HostPortPair& host_port_pair) { |
266 DCHECK(CalledOnValidThread()); | 267 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
267 if (host_port_pair.host().empty()) | 268 if (host_port_pair.host().empty()) |
268 return false; | 269 return false; |
269 | 270 |
270 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); | 271 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); |
271 } | 272 } |
272 | 273 |
273 void HttpServerPropertiesImpl::SetHTTP11Required( | 274 void HttpServerPropertiesImpl::SetHTTP11Required( |
274 const HostPortPair& host_port_pair) { | 275 const HostPortPair& host_port_pair) { |
275 DCHECK(CalledOnValidThread()); | 276 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
276 if (host_port_pair.host().empty()) | 277 if (host_port_pair.host().empty()) |
277 return; | 278 return; |
278 | 279 |
279 http11_servers_.insert(host_port_pair); | 280 http11_servers_.insert(host_port_pair); |
280 } | 281 } |
281 | 282 |
282 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, | 283 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, |
283 SSLConfig* ssl_config) { | 284 SSLConfig* ssl_config) { |
284 if (RequiresHTTP11(server)) { | 285 if (RequiresHTTP11(server)) { |
285 ForceHTTP11(ssl_config); | 286 ForceHTTP11(ssl_config); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 768 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
768 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 769 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
769 FROM_HERE, | 770 FROM_HERE, |
770 base::Bind( | 771 base::Bind( |
771 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 772 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
772 weak_ptr_factory_.GetWeakPtr()), | 773 weak_ptr_factory_.GetWeakPtr()), |
773 delay); | 774 delay); |
774 } | 775 } |
775 | 776 |
776 } // namespace net | 777 } // namespace net |
OLD | NEW |