| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const uint64_t kBrokenAlternativeProtocolDelaySecs = 300; | 26 const uint64_t kBrokenAlternativeProtocolDelaySecs = 300; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 HttpServerPropertiesImpl::HttpServerPropertiesImpl() | 30 HttpServerPropertiesImpl::HttpServerPropertiesImpl() |
| 31 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), | 31 : spdy_servers_map_(SpdyServerHostPortMap::NO_AUTO_EVICT), |
| 32 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), | 32 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), |
| 33 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), | 33 spdy_settings_map_(SpdySettingsMap::NO_AUTO_EVICT), |
| 34 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), | 34 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), |
| 35 alternative_service_probability_threshold_(1.0), | 35 alternative_service_probability_threshold_(1.0), |
| 36 quic_server_info_map_(kMaxQuicServersToPersist), | 36 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), |
| 37 number_of_server_configs_stored_in_properties_(kMaxQuicServersToPersist), |
| 37 weak_ptr_factory_(this) { | 38 weak_ptr_factory_(this) { |
| 38 canonical_suffixes_.push_back(".c.youtube.com"); | 39 canonical_suffixes_.push_back(".c.youtube.com"); |
| 39 canonical_suffixes_.push_back(".googlevideo.com"); | 40 canonical_suffixes_.push_back(".googlevideo.com"); |
| 40 canonical_suffixes_.push_back(".googleusercontent.com"); | 41 canonical_suffixes_.push_back(".googleusercontent.com"); |
| 41 } | 42 } |
| 42 | 43 |
| 43 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 44 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
| 44 } | 45 } |
| 45 | 46 |
| 46 void HttpServerPropertiesImpl::InitializeSpdyServers( | 47 void HttpServerPropertiesImpl::InitializeSpdyServers( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (server_network_stats_map_.Get(it->first) == | 178 if (server_network_stats_map_.Get(it->first) == |
| 178 server_network_stats_map_.end()) { | 179 server_network_stats_map_.end()) { |
| 179 server_network_stats_map_.Put(it->first, it->second); | 180 server_network_stats_map_.Put(it->first, it->second); |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| 184 void HttpServerPropertiesImpl::InitializeQuicServerInfoMap( | 185 void HttpServerPropertiesImpl::InitializeQuicServerInfoMap( |
| 185 QuicServerInfoMap* quic_server_info_map) { | 186 QuicServerInfoMap* quic_server_info_map) { |
| 186 // Add the entries from persisted data. | 187 // Add the entries from persisted data. |
| 187 QuicServerInfoMap temp_map(kMaxQuicServersToPersist); | 188 QuicServerInfoMap temp_map(QuicServerInfoMap::NO_AUTO_EVICT); |
| 188 for (QuicServerInfoMap::reverse_iterator it = quic_server_info_map->rbegin(); | 189 for (QuicServerInfoMap::reverse_iterator it = quic_server_info_map->rbegin(); |
| 189 it != quic_server_info_map->rend(); ++it) { | 190 it != quic_server_info_map->rend(); ++it) { |
| 190 temp_map.Put(it->first, it->second); | 191 temp_map.Put(it->first, it->second); |
| 191 } | 192 } |
| 192 | 193 |
| 193 quic_server_info_map_.Swap(temp_map); | 194 quic_server_info_map_.Swap(temp_map); |
| 194 | 195 |
| 195 // Add the entries from the memory cache. | 196 // Add the entries from the memory cache. |
| 196 for (QuicServerInfoMap::reverse_iterator it = temp_map.rbegin(); | 197 for (QuicServerInfoMap::reverse_iterator it = temp_map.rbegin(); |
| 197 it != temp_map.rend(); ++it) { | 198 it != temp_map.rend(); ++it) { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 if (it == quic_server_info_map_.end()) | 670 if (it == quic_server_info_map_.end()) |
| 670 return nullptr; | 671 return nullptr; |
| 671 return &it->second; | 672 return &it->second; |
| 672 } | 673 } |
| 673 | 674 |
| 674 const QuicServerInfoMap& HttpServerPropertiesImpl::quic_server_info_map() | 675 const QuicServerInfoMap& HttpServerPropertiesImpl::quic_server_info_map() |
| 675 const { | 676 const { |
| 676 return quic_server_info_map_; | 677 return quic_server_info_map_; |
| 677 } | 678 } |
| 678 | 679 |
| 680 int HttpServerPropertiesImpl::number_of_server_configs_stored_in_properties() |
| 681 const { |
| 682 return number_of_server_configs_stored_in_properties_; |
| 683 } |
| 684 |
| 685 void HttpServerPropertiesImpl:: |
| 686 set_number_of_server_configs_stored_in_properties( |
| 687 int number_of_server_configs_stored_in_properties) { |
| 688 number_of_server_configs_stored_in_properties_ = |
| 689 number_of_server_configs_stored_in_properties; |
| 690 |
| 691 // MRUCache doesn't allow the size of the cache to be changed. Thus create a |
| 692 // new map with the new size and add current elements and swap the new map. |
| 693 QuicServerInfoMap temp_map(number_of_server_configs_stored_in_properties_); |
| 694 for (QuicServerInfoMap::reverse_iterator it = quic_server_info_map_.rbegin(); |
| 695 it != quic_server_info_map_.rend(); ++it) { |
| 696 temp_map.Put(it->first, it->second); |
| 697 } |
| 698 |
| 699 quic_server_info_map_.Swap(temp_map); |
| 700 } |
| 701 |
| 679 void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold( | 702 void HttpServerPropertiesImpl::SetAlternativeServiceProbabilityThreshold( |
| 680 double threshold) { | 703 double threshold) { |
| 681 alternative_service_probability_threshold_ = threshold; | 704 alternative_service_probability_threshold_ = threshold; |
| 682 } | 705 } |
| 683 | 706 |
| 684 AlternativeServiceMap::const_iterator | 707 AlternativeServiceMap::const_iterator |
| 685 HttpServerPropertiesImpl::GetAlternateProtocolIterator( | 708 HttpServerPropertiesImpl::GetAlternateProtocolIterator( |
| 686 const HostPortPair& server) { | 709 const HostPortPair& server) { |
| 687 AlternativeServiceMap::const_iterator it = | 710 AlternativeServiceMap::const_iterator it = |
| 688 alternative_service_map_.Get(server); | 711 alternative_service_map_.Get(server); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 819 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
| 797 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 820 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 798 FROM_HERE, | 821 FROM_HERE, |
| 799 base::Bind( | 822 base::Bind( |
| 800 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 823 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
| 801 weak_ptr_factory_.GetWeakPtr()), | 824 weak_ptr_factory_.GetWeakPtr()), |
| 802 delay); | 825 delay); |
| 803 } | 826 } |
| 804 | 827 |
| 805 } // namespace net | 828 } // namespace net |
| OLD | NEW |