| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( | 96 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( |
| 97 SpdySettingsMap* spdy_settings_map) { | 97 SpdySettingsMap* spdy_settings_map) { |
| 98 for (SpdySettingsMap::reverse_iterator it = spdy_settings_map->rbegin(); | 98 for (SpdySettingsMap::reverse_iterator it = spdy_settings_map->rbegin(); |
| 99 it != spdy_settings_map->rend(); ++it) { | 99 it != spdy_settings_map->rend(); ++it) { |
| 100 spdy_settings_map_.Put(it->first, it->second); | 100 spdy_settings_map_.Put(it->first, it->second); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void HttpServerPropertiesImpl::InitializeSupportsQuic( | 104 void HttpServerPropertiesImpl::InitializeSupportsQuic( |
| 105 SupportsQuicMap* supports_quic_map) { | 105 IPAddressNumber* last_address) { |
| 106 for (SupportsQuicMap::reverse_iterator it = supports_quic_map->rbegin(); | 106 if (last_address) |
| 107 it != supports_quic_map->rend(); | 107 last_quic_address_ = *last_address; |
| 108 ++it) { | |
| 109 supports_quic_map_.insert(std::make_pair(it->first, it->second)); | |
| 110 } | |
| 111 } | 108 } |
| 112 | 109 |
| 113 void HttpServerPropertiesImpl::InitializeServerNetworkStats( | 110 void HttpServerPropertiesImpl::InitializeServerNetworkStats( |
| 114 ServerNetworkStatsMap* server_network_stats_map) { | 111 ServerNetworkStatsMap* server_network_stats_map) { |
| 115 for (ServerNetworkStatsMap::reverse_iterator it = | 112 for (ServerNetworkStatsMap::reverse_iterator it = |
| 116 server_network_stats_map->rbegin(); | 113 server_network_stats_map->rbegin(); |
| 117 it != server_network_stats_map->rend(); ++it) { | 114 it != server_network_stats_map->rend(); ++it) { |
| 118 server_network_stats_map_.Put(it->first, it->second); | 115 server_network_stats_map_.Put(it->first, it->second); |
| 119 } | 116 } |
| 120 } | 117 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { | 154 base::WeakPtr<HttpServerProperties> HttpServerPropertiesImpl::GetWeakPtr() { |
| 158 return weak_ptr_factory_.GetWeakPtr(); | 155 return weak_ptr_factory_.GetWeakPtr(); |
| 159 } | 156 } |
| 160 | 157 |
| 161 void HttpServerPropertiesImpl::Clear() { | 158 void HttpServerPropertiesImpl::Clear() { |
| 162 DCHECK(CalledOnValidThread()); | 159 DCHECK(CalledOnValidThread()); |
| 163 spdy_servers_map_.Clear(); | 160 spdy_servers_map_.Clear(); |
| 164 alternate_protocol_map_.Clear(); | 161 alternate_protocol_map_.Clear(); |
| 165 canonical_host_to_origin_map_.clear(); | 162 canonical_host_to_origin_map_.clear(); |
| 166 spdy_settings_map_.Clear(); | 163 spdy_settings_map_.Clear(); |
| 167 supports_quic_map_.clear(); | 164 last_quic_address_.clear(); |
| 168 server_network_stats_map_.Clear(); | 165 server_network_stats_map_.Clear(); |
| 169 } | 166 } |
| 170 | 167 |
| 171 bool HttpServerPropertiesImpl::SupportsRequestPriority( | 168 bool HttpServerPropertiesImpl::SupportsRequestPriority( |
| 172 const HostPortPair& host_port_pair) { | 169 const HostPortPair& host_port_pair) { |
| 173 DCHECK(CalledOnValidThread()); | 170 DCHECK(CalledOnValidThread()); |
| 174 if (host_port_pair.host().empty()) | 171 if (host_port_pair.host().empty()) |
| 175 return false; | 172 return false; |
| 176 | 173 |
| 177 SpdyServerHostPortMap::iterator spdy_host_port = | 174 SpdyServerHostPortMap::iterator spdy_host_port = |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 401 |
| 405 void HttpServerPropertiesImpl::ClearAllSpdySettings() { | 402 void HttpServerPropertiesImpl::ClearAllSpdySettings() { |
| 406 spdy_settings_map_.Clear(); | 403 spdy_settings_map_.Clear(); |
| 407 } | 404 } |
| 408 | 405 |
| 409 const SpdySettingsMap& | 406 const SpdySettingsMap& |
| 410 HttpServerPropertiesImpl::spdy_settings_map() const { | 407 HttpServerPropertiesImpl::spdy_settings_map() const { |
| 411 return spdy_settings_map_; | 408 return spdy_settings_map_; |
| 412 } | 409 } |
| 413 | 410 |
| 414 SupportsQuic HttpServerPropertiesImpl::GetSupportsQuic( | 411 bool HttpServerPropertiesImpl::GetSupportsQuic( |
| 415 const HostPortPair& host_port_pair) const { | 412 IPAddressNumber* last_address) const { |
| 416 SupportsQuicMap::const_iterator it = supports_quic_map_.find(host_port_pair); | 413 if (last_quic_address_.empty()) |
| 417 if (it == supports_quic_map_.end()) { | 414 return false; |
| 418 CR_DEFINE_STATIC_LOCAL(SupportsQuic, kEmptySupportsQuic, ()); | 415 |
| 419 return kEmptySupportsQuic; | 416 *last_address = last_quic_address_; |
| 420 } | 417 return true; |
| 421 return it->second; | |
| 422 } | 418 } |
| 423 | 419 |
| 424 void HttpServerPropertiesImpl::SetSupportsQuic( | 420 void HttpServerPropertiesImpl::SetSupportsQuic(bool used_quic, |
| 425 const HostPortPair& host_port_pair, | 421 const IPAddressNumber& address) { |
| 426 bool used_quic, | 422 if (!used_quic) { |
| 427 const std::string& address) { | 423 last_quic_address_.clear(); |
| 428 SupportsQuic supports_quic(used_quic, address); | 424 } else { |
| 429 supports_quic_map_.insert(std::make_pair(host_port_pair, supports_quic)); | 425 last_quic_address_ = address; |
| 430 } | 426 } |
| 431 | |
| 432 const SupportsQuicMap& HttpServerPropertiesImpl::supports_quic_map() const { | |
| 433 return supports_quic_map_; | |
| 434 } | 427 } |
| 435 | 428 |
| 436 void HttpServerPropertiesImpl::SetServerNetworkStats( | 429 void HttpServerPropertiesImpl::SetServerNetworkStats( |
| 437 const HostPortPair& host_port_pair, | 430 const HostPortPair& host_port_pair, |
| 438 ServerNetworkStats stats) { | 431 ServerNetworkStats stats) { |
| 439 server_network_stats_map_.Put(host_port_pair, stats); | 432 server_network_stats_map_.Put(host_port_pair, stats); |
| 440 } | 433 } |
| 441 | 434 |
| 442 const ServerNetworkStats* HttpServerPropertiesImpl::GetServerNetworkStats( | 435 const ServerNetworkStats* HttpServerPropertiesImpl::GetServerNetworkStats( |
| 443 const HostPortPair& host_port_pair) { | 436 const HostPortPair& host_port_pair) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 516 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 524 base::MessageLoop::current()->PostDelayedTask( | 517 base::MessageLoop::current()->PostDelayedTask( |
| 525 FROM_HERE, | 518 FROM_HERE, |
| 526 base::Bind( | 519 base::Bind( |
| 527 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 520 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 528 weak_ptr_factory_.GetWeakPtr()), | 521 weak_ptr_factory_.GetWeakPtr()), |
| 529 delay); | 522 delay); |
| 530 } | 523 } |
| 531 | 524 |
| 532 } // namespace net | 525 } // namespace net |
| OLD | NEW |