Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: net/http/http_server_properties_impl.cc

Issue 2932953002: Persist broken and recently-broken alt-svcs to prefs in HttpServerPropertiesManager (Closed)
Patch Set: More cleanup Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
Ryan Hamilton 2017/07/06 16:48:22 Alternatively, you could pass in nullptr and the o
wangyix1 2017/07/06 18:04:29 Done.
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Get the list of servers (scheme/host/port) that support SPDY. 167 // Get the list of servers (scheme/host/port) that support SPDY.
159 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin(); 168 for (SpdyServersMap::const_iterator it = spdy_servers_map_.begin();
160 it != spdy_servers_map_.end() && count < max_size; ++it) { 169 it != spdy_servers_map_.end() && count < max_size; ++it) {
161 if (it->second) { 170 if (it->second) {
162 spdy_servers->push_back(it->first); 171 spdy_servers->push_back(it->first);
163 ++count; 172 ++count;
164 } 173 }
165 } 174 }
166 } 175 }
167 176
177 void HttpServerPropertiesImpl::SetBrokenAndRecentlyBrokenAlternativeServices(
178 std::unique_ptr<BrokenAlternativeServiceList>
179 broken_alternative_service_list,
180 std::unique_ptr<RecentlyBrokenAlternativeServices>
181 recently_broken_alternative_services) {
182 broken_alternative_services_.SetBrokenAndRecentlyBrokenAlternativeServices(
183 std::move(broken_alternative_service_list),
184 std::move(recently_broken_alternative_services));
185 }
186
187 const BrokenAlternativeServiceList&
188 HttpServerPropertiesImpl::broken_alternative_service_list() const {
189 return broken_alternative_services_.broken_alternative_service_list();
190 }
191
192 const RecentlyBrokenAlternativeServices&
193 HttpServerPropertiesImpl::recently_broken_alternative_services() const {
194 return broken_alternative_services_.recently_broken_alternative_services();
195 }
196
168 void HttpServerPropertiesImpl::Clear() { 197 void HttpServerPropertiesImpl::Clear() {
169 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); 198 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
170 spdy_servers_map_.Clear(); 199 spdy_servers_map_.Clear();
171 alternative_service_map_.Clear(); 200 alternative_service_map_.Clear();
172 canonical_host_to_origin_map_.clear(); 201 canonical_host_to_origin_map_.clear();
173 last_quic_address_ = IPAddress(); 202 last_quic_address_ = IPAddress();
174 server_network_stats_map_.Clear(); 203 server_network_stats_map_.Clear();
175 quic_server_info_map_.Clear(); 204 quic_server_info_map_.Clear();
176 } 205 }
177 206
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 if (map_it->second.empty()) { 689 if (map_it->second.empty()) {
661 RemoveCanonicalHost(map_it->first); 690 RemoveCanonicalHost(map_it->first);
662 map_it = alternative_service_map_.Erase(map_it); 691 map_it = alternative_service_map_.Erase(map_it);
663 continue; 692 continue;
664 } 693 }
665 ++map_it; 694 ++map_it;
666 } 695 }
667 } 696 }
668 697
669 } // namespace net 698 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698