| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 HttpServerPropertiesImpl::HttpServerPropertiesImpl() | 23 HttpServerPropertiesImpl::HttpServerPropertiesImpl() |
| 24 : HttpServerPropertiesImpl(&broken_alternative_services_clock_) {} | 24 : spdy_servers_map_(SpdyServersMap::NO_AUTO_EVICT), |
| 25 | |
| 26 HttpServerPropertiesImpl::HttpServerPropertiesImpl( | |
| 27 base::TickClock* broken_alternative_services_clock) | |
| 28 : broken_alternative_services_(this, broken_alternative_services_clock), | |
| 29 spdy_servers_map_(SpdyServersMap::NO_AUTO_EVICT), | |
| 30 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), | 25 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), |
| 26 broken_alternative_services_(this), |
| 31 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), | 27 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), |
| 32 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), | 28 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), |
| 33 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { | 29 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { |
| 34 canonical_suffixes_.push_back(".ggpht.com"); | 30 canonical_suffixes_.push_back(".ggpht.com"); |
| 35 canonical_suffixes_.push_back(".c.youtube.com"); | 31 canonical_suffixes_.push_back(".c.youtube.com"); |
| 36 canonical_suffixes_.push_back(".googlevideo.com"); | 32 canonical_suffixes_.push_back(".googlevideo.com"); |
| 37 canonical_suffixes_.push_back(".googleusercontent.com"); | 33 canonical_suffixes_.push_back(".googleusercontent.com"); |
| 38 } | 34 } |
| 39 | 35 |
| 40 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 36 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); | 186 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); |
| 191 it != spdy_servers_map_.end() && count < max_size; ++it) { | 187 it != spdy_servers_map_.end() && count < max_size; ++it) { |
| 192 const std::string spdy_server = it->first; | 188 const std::string spdy_server = it->first; |
| 193 if (it->second) { | 189 if (it->second) { |
| 194 spdy_server_list->AppendString(spdy_server); | 190 spdy_server_list->AppendString(spdy_server); |
| 195 ++count; | 191 ++count; |
| 196 } | 192 } |
| 197 } | 193 } |
| 198 } | 194 } |
| 199 | 195 |
| 196 void HttpServerPropertiesImpl::AddBrokenAndRecentlyBrokenAlternativeServices( |
| 197 std::unique_ptr<BrokenAlternativeServiceList> |
| 198 broken_alternative_service_list, |
| 199 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 200 recently_broken_alternative_services) { |
| 201 broken_alternative_services_.AddBrokenAndRecentlyBrokenAlternativeServices( |
| 202 std::move(broken_alternative_service_list), |
| 203 std::move(recently_broken_alternative_services)); |
| 204 } |
| 205 |
| 206 const BrokenAlternativeServiceList& |
| 207 HttpServerPropertiesImpl::broken_alternative_service_list() const { |
| 208 return broken_alternative_services_.broken_alternative_service_list(); |
| 209 } |
| 210 |
| 211 const RecentlyBrokenAlternativeServices& |
| 212 HttpServerPropertiesImpl::recently_broken_alternative_services() const { |
| 213 return broken_alternative_services_.recently_broken_alternative_services(); |
| 214 } |
| 215 |
| 200 void HttpServerPropertiesImpl::Clear() { | 216 void HttpServerPropertiesImpl::Clear() { |
| 201 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 217 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 202 spdy_servers_map_.Clear(); | 218 spdy_servers_map_.Clear(); |
| 203 alternative_service_map_.Clear(); | 219 alternative_service_map_.Clear(); |
| 220 broken_alternative_services_.Clear(); |
| 204 canonical_host_to_origin_map_.clear(); | 221 canonical_host_to_origin_map_.clear(); |
| 205 last_quic_address_ = IPAddress(); | 222 last_quic_address_ = IPAddress(); |
| 206 server_network_stats_map_.Clear(); | 223 server_network_stats_map_.Clear(); |
| 207 quic_server_info_map_.Clear(); | 224 quic_server_info_map_.Clear(); |
| 208 } | 225 } |
| 209 | 226 |
| 210 bool HttpServerPropertiesImpl::SupportsRequestPriority( | 227 bool HttpServerPropertiesImpl::SupportsRequestPriority( |
| 211 const url::SchemeHostPort& server) { | 228 const url::SchemeHostPort& server) { |
| 212 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 229 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 213 if (server.host().empty()) | 230 if (server.host().empty()) |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 // |alternative_service_map_|. | 708 // |alternative_service_map_|. |
| 692 if (map_it->second.empty()) { | 709 if (map_it->second.empty()) { |
| 693 RemoveCanonicalHost(map_it->first); | 710 RemoveCanonicalHost(map_it->first); |
| 694 map_it = alternative_service_map_.Erase(map_it); | 711 map_it = alternative_service_map_.Erase(map_it); |
| 695 continue; | 712 continue; |
| 696 } | 713 } |
| 697 ++map_it; | 714 ++map_it; |
| 698 } | 715 } |
| 699 } | 716 } |
| 700 | 717 |
| 718 void HttpServerPropertiesImpl::SetBrokenAlternativeServicesTickClockForTesting( |
| 719 base::TickClock* clock) { |
| 720 DCHECK(clock); |
| 721 broken_alternative_services_.SetTickClockForTesting(clock); |
| 722 } |
| 723 |
| 701 } // namespace net | 724 } // namespace net |
| OLD | NEW |