diff options
Diffstat (limited to 'chromium/net/http/http_server_properties_manager.cc')
-rw-r--r-- | chromium/net/http/http_server_properties_manager.cc | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/chromium/net/http/http_server_properties_manager.cc b/chromium/net/http/http_server_properties_manager.cc index 389487143e3..af84c1d48ba 100644 --- a/chromium/net/http/http_server_properties_manager.cc +++ b/chromium/net/http/http_server_properties_manager.cc @@ -86,6 +86,16 @@ struct ServerPref { ServerNetworkStats server_network_stats; }; +QuicServerId QuicServerIdFromString(const std::string& str) { + GURL url(str); + if (!url.is_valid()) { + return QuicServerId(); + } + return QuicServerId(HostPortPair::FromURL(url), url.path_piece() == "/private" + ? PRIVACY_MODE_ENABLED + : PRIVACY_MODE_DISABLED); +} + } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -98,7 +108,7 @@ HttpServerPropertiesManager::HttpServerPropertiesManager( NetLog* net_log, base::TickClock* clock) : pref_delegate_(std::move(pref_delegate)), - clock_(clock ? clock : &default_clock_), + clock_(clock ? clock : base::DefaultTickClock::GetInstance()), net_log_( NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_SERVER_PROPERTIES)) { @@ -106,9 +116,9 @@ HttpServerPropertiesManager::HttpServerPropertiesManager( DCHECK(pref_delegate_); DCHECK(clock_); - pref_delegate_->StartListeningForUpdates( - base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged, - base::Unretained(this))); + pref_delegate_->StartListeningForUpdates(base::BindRepeating( + &HttpServerPropertiesManager::OnHttpServerPropertiesChanged, + base::Unretained(this))); net_log_.BeginEvent(NetLogEventType::HTTP_SERVER_PROPERTIES_INITIALIZATION); http_server_properties_impl_.reset(new HttpServerPropertiesImpl(clock_)); @@ -117,7 +127,7 @@ HttpServerPropertiesManager::HttpServerPropertiesManager( HttpServerPropertiesManager::~HttpServerPropertiesManager() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); // Flush settings on destruction. - UpdatePrefsFromCache(); + UpdatePrefsFromCache(base::OnceClosure()); } // static @@ -131,11 +141,11 @@ void HttpServerPropertiesManager::SetVersion( http_server_properties_dict->SetInteger(kVersionKey, version_number); } -void HttpServerPropertiesManager::Clear() { +void HttpServerPropertiesManager::Clear(base::OnceClosure callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - http_server_properties_impl_->Clear(); - UpdatePrefsFromCache(); + http_server_properties_impl_->Clear(base::OnceClosure()); + UpdatePrefsFromCache(std::move(callback)); } bool HttpServerPropertiesManager::SupportsRequestPriority( @@ -773,7 +783,6 @@ bool HttpServerPropertiesManager::ParseAlternativeServiceInfoDictOfServer( alternative_service_info->set_alternative_service(alternative_service); // Expiration is optional, defaults to one day. - base::Time expiration; if (!dict.HasKey(kExpirationKey)) { alternative_service_info->set_expiration(base::Time::Now() + base::TimeDelta::FromDays(1)); @@ -928,9 +937,8 @@ bool HttpServerPropertiesManager::AddToQuicServerInfoMap( it.Advance()) { // Get quic_server_id. const std::string& quic_server_id_str = it.key(); - QuicServerId quic_server_id; - QuicHostnameUtils::StringToQuicServerId(quic_server_id_str, - &quic_server_id); + + QuicServerId quic_server_id = QuicServerIdFromString(quic_server_id_str); if (quic_server_id.host().empty()) { DVLOG(1) << "Malformed http_server_properties for quic server: " << quic_server_id_str; @@ -969,15 +977,17 @@ void HttpServerPropertiesManager::ScheduleUpdatePrefs(Location location) { return; network_prefs_update_timer_.Start( - FROM_HERE, kUpdatePrefsDelay, this, - &HttpServerPropertiesManager::UpdatePrefsFromCache); + FROM_HERE, kUpdatePrefsDelay, + base::Bind(&HttpServerPropertiesManager::UpdatePrefsFromCache, + base::Unretained(this), base::Passed(base::OnceClosure()))); // TODO(rtenneti): Delete the following histogram after collecting some data. UMA_HISTOGRAM_ENUMERATION("Net.HttpServerProperties.UpdatePrefs", location, HttpServerPropertiesManager::NUM_LOCATIONS); } -void HttpServerPropertiesManager::UpdatePrefsFromCache() { +void HttpServerPropertiesManager::UpdatePrefsFromCache( + base::OnceClosure callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); typedef base::MRUCache<url::SchemeHostPort, ServerPref> ServerPrefMap; @@ -1105,7 +1115,8 @@ void HttpServerPropertiesManager::UpdatePrefsFromCache() { &http_server_properties_dict); setting_prefs_ = true; - pref_delegate_->SetServerProperties(http_server_properties_dict); + pref_delegate_->SetServerProperties(http_server_properties_dict, + std::move(callback)); setting_prefs_ = false; net_log_.AddEvent(NetLogEventType::HTTP_SERVER_PROPERTIES_UPDATE_PREFS, |