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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 SpdyServerHostPortMap::iterator spdy_host_port = | 191 SpdyServerHostPortMap::iterator spdy_host_port = |
192 spdy_servers_map_.Get(host_port_pair.ToString()); | 192 spdy_servers_map_.Get(host_port_pair.ToString()); |
193 if ((spdy_host_port != spdy_servers_map_.end()) && | 193 if ((spdy_host_port != spdy_servers_map_.end()) && |
194 (spdy_host_port->second == support_spdy)) { | 194 (spdy_host_port->second == support_spdy)) { |
195 return; | 195 return; |
196 } | 196 } |
197 // Cache the data. | 197 // Cache the data. |
198 spdy_servers_map_.Put(host_port_pair.ToString(), support_spdy); | 198 spdy_servers_map_.Put(host_port_pair.ToString(), support_spdy); |
199 } | 199 } |
200 | 200 |
| 201 bool HttpServerPropertiesImpl::RequiresHTTP11( |
| 202 const net::HostPortPair& host_port_pair) { |
| 203 DCHECK(CalledOnValidThread()); |
| 204 if (host_port_pair.host().empty()) |
| 205 return false; |
| 206 |
| 207 return (http11_servers_.find(host_port_pair) != http11_servers_.end()); |
| 208 } |
| 209 |
| 210 void HttpServerPropertiesImpl::SetHTTP11Required( |
| 211 const net::HostPortPair& host_port_pair) { |
| 212 DCHECK(CalledOnValidThread()); |
| 213 if (host_port_pair.host().empty()) |
| 214 return; |
| 215 |
| 216 http11_servers_.insert(host_port_pair); |
| 217 } |
| 218 |
| 219 void HttpServerPropertiesImpl::MaybeForceHTTP11(const HostPortPair& server, |
| 220 SSLConfig* ssl_config) { |
| 221 if (RequiresHTTP11(server)) { |
| 222 ForceHTTP11(ssl_config); |
| 223 } |
| 224 } |
| 225 |
201 bool HttpServerPropertiesImpl::HasAlternateProtocol( | 226 bool HttpServerPropertiesImpl::HasAlternateProtocol( |
202 const HostPortPair& server) { | 227 const HostPortPair& server) { |
203 if (g_forced_alternate_protocol) | 228 if (g_forced_alternate_protocol) |
204 return true; | 229 return true; |
205 AlternateProtocolMap::const_iterator it = alternate_protocol_map_.Get(server); | 230 AlternateProtocolMap::const_iterator it = alternate_protocol_map_.Get(server); |
206 if (it != alternate_protocol_map_.end()) | 231 if (it != alternate_protocol_map_.end()) |
207 return it->second.probability >= alternate_protocol_probability_threshold_; | 232 return it->second.probability >= alternate_protocol_probability_threshold_; |
208 | 233 |
209 auto canonical = GetCanonicalHost(server); | 234 auto canonical = GetCanonicalHost(server); |
210 if (canonical == canonical_host_to_origin_map_.end() || | 235 if (canonical == canonical_host_to_origin_map_.end() || |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 528 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
504 base::MessageLoop::current()->PostDelayedTask( | 529 base::MessageLoop::current()->PostDelayedTask( |
505 FROM_HERE, | 530 FROM_HERE, |
506 base::Bind( | 531 base::Bind( |
507 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 532 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
508 weak_ptr_factory_.GetWeakPtr()), | 533 weak_ptr_factory_.GetWeakPtr()), |
509 delay); | 534 delay); |
510 } | 535 } |
511 | 536 |
512 } // namespace net | 537 } // namespace net |
OLD | NEW |