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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 413 |
417 void HttpServerPropertiesImpl::ClearAllSpdySettings() { | 414 void HttpServerPropertiesImpl::ClearAllSpdySettings() { |
418 spdy_settings_map_.Clear(); | 415 spdy_settings_map_.Clear(); |
419 } | 416 } |
420 | 417 |
421 const SpdySettingsMap& | 418 const SpdySettingsMap& |
422 HttpServerPropertiesImpl::spdy_settings_map() const { | 419 HttpServerPropertiesImpl::spdy_settings_map() const { |
423 return spdy_settings_map_; | 420 return spdy_settings_map_; |
424 } | 421 } |
425 | 422 |
426 SupportsQuic HttpServerPropertiesImpl::GetSupportsQuic( | 423 bool HttpServerPropertiesImpl::GetSupportsQuic( |
427 const HostPortPair& host_port_pair) const { | 424 IPAddressNumber* last_address) const { |
428 SupportsQuicMap::const_iterator it = supports_quic_map_.find(host_port_pair); | 425 if (last_quic_address_.empty()) |
429 if (it == supports_quic_map_.end()) { | 426 return false; |
430 CR_DEFINE_STATIC_LOCAL(SupportsQuic, kEmptySupportsQuic, ()); | 427 |
431 return kEmptySupportsQuic; | 428 *last_address = last_quic_address_; |
432 } | 429 return true; |
433 return it->second; | |
434 } | 430 } |
435 | 431 |
436 void HttpServerPropertiesImpl::SetSupportsQuic( | 432 void HttpServerPropertiesImpl::SetSupportsQuic(bool used_quic, |
437 const HostPortPair& host_port_pair, | 433 const IPAddressNumber& address) { |
438 bool used_quic, | 434 if (!used_quic) { |
439 const std::string& address) { | 435 last_quic_address_.clear(); |
440 SupportsQuic supports_quic(used_quic, address); | 436 } else { |
441 supports_quic_map_.insert(std::make_pair(host_port_pair, supports_quic)); | 437 last_quic_address_ = address; |
442 } | 438 } |
443 | |
444 const SupportsQuicMap& HttpServerPropertiesImpl::supports_quic_map() const { | |
445 return supports_quic_map_; | |
446 } | 439 } |
447 | 440 |
448 void HttpServerPropertiesImpl::SetServerNetworkStats( | 441 void HttpServerPropertiesImpl::SetServerNetworkStats( |
449 const HostPortPair& host_port_pair, | 442 const HostPortPair& host_port_pair, |
450 ServerNetworkStats stats) { | 443 ServerNetworkStats stats) { |
451 server_network_stats_map_.Put(host_port_pair, stats); | 444 server_network_stats_map_.Put(host_port_pair, stats); |
452 } | 445 } |
453 | 446 |
454 const ServerNetworkStats* HttpServerPropertiesImpl::GetServerNetworkStats( | 447 const ServerNetworkStats* HttpServerPropertiesImpl::GetServerNetworkStats( |
455 const HostPortPair& host_port_pair) { | 448 const HostPortPair& host_port_pair) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 528 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
536 base::MessageLoop::current()->PostDelayedTask( | 529 base::MessageLoop::current()->PostDelayedTask( |
537 FROM_HERE, | 530 FROM_HERE, |
538 base::Bind( | 531 base::Bind( |
539 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 532 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
540 weak_ptr_factory_.GetWeakPtr()), | 533 weak_ptr_factory_.GetWeakPtr()), |
541 delay); | 534 delay); |
542 } | 535 } |
543 | 536 |
544 } // namespace net | 537 } // namespace net |
OLD | NEW |