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), |
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) { |
| 30 canonical_suffixes_.push_back(".ggpht.com"); |
| 31 canonical_suffixes_.push_back(".c.youtube.com"); |
| 32 canonical_suffixes_.push_back(".googlevideo.com"); |
| 33 canonical_suffixes_.push_back(".googleusercontent.com"); |
| 34 } |
| 35 |
| 36 // Can't just call delegate constructor |
| 37 // HttpServerPropertiesImpl(&default_clock_) due to UBSan; |default_clock_|'s |
| 38 // lifetime would not have begun yet. |
| 39 HttpServerPropertiesImpl::HttpServerPropertiesImpl() |
| 40 : spdy_servers_map_(SpdyServersMap::NO_AUTO_EVICT), |
| 41 alternative_service_map_(AlternativeServiceMap::NO_AUTO_EVICT), |
| 42 broken_alternative_services_(this, &default_clock_), |
| 43 server_network_stats_map_(ServerNetworkStatsMap::NO_AUTO_EVICT), |
| 44 quic_server_info_map_(QuicServerInfoMap::NO_AUTO_EVICT), |
| 45 max_server_configs_stored_in_properties_(kMaxQuicServersToPersist) { |
37 canonical_suffixes_.push_back(".ggpht.com"); | 46 canonical_suffixes_.push_back(".ggpht.com"); |
38 canonical_suffixes_.push_back(".c.youtube.com"); | 47 canonical_suffixes_.push_back(".c.youtube.com"); |
39 canonical_suffixes_.push_back(".googlevideo.com"); | 48 canonical_suffixes_.push_back(".googlevideo.com"); |
40 canonical_suffixes_.push_back(".googleusercontent.com"); | 49 canonical_suffixes_.push_back(".googleusercontent.com"); |
41 } | 50 } |
42 | 51 |
43 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { | 52 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() { |
44 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 53 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
45 } | 54 } |
46 | 55 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); | 202 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); |
194 it != spdy_servers_map_.end() && count < max_size; ++it) { | 203 it != spdy_servers_map_.end() && count < max_size; ++it) { |
195 const std::string spdy_server = it->first; | 204 const std::string spdy_server = it->first; |
196 if (it->second) { | 205 if (it->second) { |
197 spdy_server_list->AppendString(spdy_server); | 206 spdy_server_list->AppendString(spdy_server); |
198 ++count; | 207 ++count; |
199 } | 208 } |
200 } | 209 } |
201 } | 210 } |
202 | 211 |
| 212 void HttpServerPropertiesImpl::SetBrokenAndRecentlyBrokenAlternativeServices( |
| 213 std::unique_ptr<BrokenAlternativeServiceList> |
| 214 broken_alternative_service_list, |
| 215 std::unique_ptr<RecentlyBrokenAlternativeServices> |
| 216 recently_broken_alternative_services) { |
| 217 broken_alternative_services_.SetBrokenAndRecentlyBrokenAlternativeServices( |
| 218 std::move(broken_alternative_service_list), |
| 219 std::move(recently_broken_alternative_services)); |
| 220 } |
| 221 |
| 222 const BrokenAlternativeServiceList& |
| 223 HttpServerPropertiesImpl::broken_alternative_service_list() const { |
| 224 return broken_alternative_services_.broken_alternative_service_list(); |
| 225 } |
| 226 |
| 227 const RecentlyBrokenAlternativeServices& |
| 228 HttpServerPropertiesImpl::recently_broken_alternative_services() const { |
| 229 return broken_alternative_services_.recently_broken_alternative_services(); |
| 230 } |
| 231 |
203 void HttpServerPropertiesImpl::Clear() { | 232 void HttpServerPropertiesImpl::Clear() { |
204 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 233 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
205 spdy_servers_map_.Clear(); | 234 spdy_servers_map_.Clear(); |
206 alternative_service_map_.Clear(); | 235 alternative_service_map_.Clear(); |
207 canonical_host_to_origin_map_.clear(); | 236 canonical_host_to_origin_map_.clear(); |
208 last_quic_address_ = IPAddress(); | 237 last_quic_address_ = IPAddress(); |
209 server_network_stats_map_.Clear(); | 238 server_network_stats_map_.Clear(); |
210 quic_server_info_map_.Clear(); | 239 quic_server_info_map_.Clear(); |
211 } | 240 } |
212 | 241 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 if (map_it->second.empty()) { | 724 if (map_it->second.empty()) { |
696 RemoveCanonicalHost(map_it->first); | 725 RemoveCanonicalHost(map_it->first); |
697 map_it = alternative_service_map_.Erase(map_it); | 726 map_it = alternative_service_map_.Erase(map_it); |
698 continue; | 727 continue; |
699 } | 728 } |
700 ++map_it; | 729 ++map_it; |
701 } | 730 } |
702 } | 731 } |
703 | 732 |
704 } // namespace net | 733 } // namespace net |
OLD | NEW |