| 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(base::TickClock* clock) |
| 24 : HttpServerPropertiesImpl(nullptr) {} | 24 : spdy_servers_map_(SpdyServersMap::NO_AUTO_EVICT), |
| 25 | |
| 26 HttpServerPropertiesImpl::HttpServerPropertiesImpl( | |
| 27 base::TickClock* broken_alternative_services_clock) | |
| 28 : broken_alternative_services_(this, | |
| 29 broken_alternative_services_clock | |
| 30 ? broken_alternative_services_clock | |
| 31 : &broken_alternative_services_clock_), | |
| 32 spdy_servers_map_(SpdyServersMap::NO_AUTO_EVICT), | |
| 33 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), | 25 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), |
| 26 broken_alternative_services_(this, clock ? clock : &default_clock_), |
| 34 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), | 27 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), |
| 35 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), | 28 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), |
| 36 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { | 29 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { |
| 37 canonical_suffixes_.push_back(".ggpht.com"); | 30 canonical_suffixes_.push_back(".ggpht.com"); |
| 38 canonical_suffixes_.push_back(".c.youtube.com"); | 31 canonical_suffixes_.push_back(".c.youtube.com"); |
| 39 canonical_suffixes_.push_back(".googlevideo.com"); | 32 canonical_suffixes_.push_back(".googlevideo.com"); |
| 40 canonical_suffixes_.push_back(".googleusercontent.com"); | 33 canonical_suffixes_.push_back(".googleusercontent.com"); |
| 41 } | 34 } |
| 42 | 35 |
| 36 HttpServerPropertiesImpl::HttpServerPropertiesImpl() |
| 37 : HttpServerPropertiesImpl(nullptr) {} |
| 38 |
| 43 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 39 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
| 44 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 40 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 45 } | 41 } |
| 46 | 42 |
| 47 void HttpServerPropertiesImpl::SetSpdyServers( | 43 void HttpServerPropertiesImpl::SetSpdyServers( |
| 48 std::unique_ptr<SpdyServersMap> spdy_servers_map) { | 44 std::unique_ptr<SpdyServersMap> spdy_servers_map) { |
| 49 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 45 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 50 | 46 |
| 51 // Add the entries from persisted data. | 47 // Add the entries from persisted data. |
| 52 spdy_servers_map_.Swap(*spdy_servers_map); | 48 spdy_servers_map_.Swap(*spdy_servers_map); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Get the list of servers (scheme/host/port) that support SPDY. | 154 // Get the list of servers (scheme/host/port) that support SPDY. |
| 159 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); | 155 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); |
| 160 it != spdy_servers_map_.end() && count < max_size; ++it) { | 156 it != spdy_servers_map_.end() && count < max_size; ++it) { |
| 161 if (it->second) { | 157 if (it->second) { |
| 162 spdy_servers->push_back(it->first); | 158 spdy_servers->push_back(it->first); |
| 163 ++count; | 159 ++count; |
| 164 } | 160 } |
| 165 } | 161 } |
| 166 } | 162 } |
| 167 | 163 |
| 164 void HttpServerPropertiesImpl::SetBrokenAndRecentlyBrokenAlternativeServices( |
| 165 std::unique_ptr<BrokenAlternativeServiceList> |
| 166 broken_alternative_service_list, |
| 167 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 168 recently_broken_alternative_services) { |
| 169 broken_alternative_services_.SetBrokenAndRecentlyBrokenAlternativeServices( |
| 170 std::move(broken_alternative_service_list), |
| 171 std::move(recently_broken_alternative_services)); |
| 172 } |
| 173 |
| 174 const BrokenAlternativeServiceList& |
| 175 HttpServerPropertiesImpl::broken_alternative_service_list() const { |
| 176 return broken_alternative_services_.broken_alternative_service_list(); |
| 177 } |
| 178 |
| 179 const RecentlyBrokenAlternativeServices& |
| 180 HttpServerPropertiesImpl::recently_broken_alternative_services() const { |
| 181 return broken_alternative_services_.recently_broken_alternative_services(); |
| 182 } |
| 183 |
| 168 void HttpServerPropertiesImpl::Clear() { | 184 void HttpServerPropertiesImpl::Clear() { |
| 169 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 185 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 170 spdy_servers_map_.Clear(); | 186 spdy_servers_map_.Clear(); |
| 171 alternative_service_map_.Clear(); | 187 alternative_service_map_.Clear(); |
| 172 canonical_host_to_origin_map_.clear(); | 188 canonical_host_to_origin_map_.clear(); |
| 173 last_quic_address_ = IPAddress(); | 189 last_quic_address_ = IPAddress(); |
| 174 server_network_stats_map_.Clear(); | 190 server_network_stats_map_.Clear(); |
| 175 quic_server_info_map_.Clear(); | 191 quic_server_info_map_.Clear(); |
| 176 } | 192 } |
| 177 | 193 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 if (map_it->second.empty()) { | 676 if (map_it->second.empty()) { |
| 661 RemoveCanonicalHost(map_it->first); | 677 RemoveCanonicalHost(map_it->first); |
| 662 map_it = alternative_service_map_.Erase(map_it); | 678 map_it = alternative_service_map_.Erase(map_it); |
| 663 continue; | 679 continue; |
| 664 } | 680 } |
| 665 ++map_it; | 681 ++map_it; |
| 666 } | 682 } |
| 667 } | 683 } |
| 668 | 684 |
| 669 } // namespace net | 685 } // namespace net |
| OLD | NEW |