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

Unified Diff: net/http/http_server_properties_manager.cc

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_server_properties_manager.cc
diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc
index a592f441bb09eb71cb7371d421b33e5fb63f5600..3bf9d78a5ebcc5cedc80a69c15ddb09c37e4d2c9 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -145,7 +145,7 @@ void HttpServerPropertiesManager::Clear(const base::Closure& completion) {
}
bool HttpServerPropertiesManager::SupportsRequestPriority(
- const HostPortPair& server) {
+ const url::SchemeHostPort& server) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
return http_server_properties_impl_->SupportsRequestPriority(server);
}
@@ -186,13 +186,13 @@ void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server,
}
AlternativeServiceVector HttpServerPropertiesManager::GetAlternativeServices(
- const HostPortPair& origin) {
+ const url::SchemeHostPort& origin) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
return http_server_properties_impl_->GetAlternativeServices(origin);
}
bool HttpServerPropertiesManager::SetAlternativeService(
- const HostPortPair& origin,
+ const url::SchemeHostPort& origin,
const AlternativeService& alternative_service,
base::Time expiration) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
@@ -205,7 +205,7 @@ bool HttpServerPropertiesManager::SetAlternativeService(
}
bool HttpServerPropertiesManager::SetAlternativeServices(
- const HostPortPair& origin,
+ const url::SchemeHostPort& origin,
const AlternativeServiceInfoVector& alternative_service_info_vector) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
const bool changed = http_server_properties_impl_->SetAlternativeServices(
@@ -261,7 +261,7 @@ void HttpServerPropertiesManager::ConfirmAlternativeService(
}
void HttpServerPropertiesManager::ClearAlternativeServices(
- const HostPortPair& origin) {
+ const url::SchemeHostPort& origin) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
const AlternativeServiceMap& map =
http_server_properties_impl_->alternative_service_map();
@@ -503,7 +503,7 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
if (version < 4) {
if (!AddServersData(*servers_dict, spdy_servers.get(),
spdy_settings_map.get(), alternative_service_map.get(),
- server_network_stats_map.get())) {
+ server_network_stats_map.get(), version)) {
detected_corrupted_prefs = true;
}
} else {
@@ -514,9 +514,10 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
detected_corrupted_prefs = true;
continue;
}
- if (!AddServersData(
- *servers_dict, spdy_servers.get(), spdy_settings_map.get(),
- alternative_service_map.get(), server_network_stats_map.get())) {
+ if (!AddServersData(*servers_dict, spdy_servers.get(),
+ spdy_settings_map.get(),
+ alternative_service_map.get(),
+ server_network_stats_map.get(), version)) {
detected_corrupted_prefs = true;
}
}
@@ -544,7 +545,8 @@ bool HttpServerPropertiesManager::AddServersData(
ServerList* spdy_servers,
SpdySettingsMap* spdy_settings_map,
AlternativeServiceMap* alternative_service_map,
- ServerNetworkStatsMap* network_stats_map) {
+ ServerNetworkStatsMap* network_stats_map,
+ int version) {
for (base::DictionaryValue::Iterator it(servers_dict); !it.IsAtEnd();
it.Advance()) {
// Get server's host/pair.
@@ -569,7 +571,15 @@ bool HttpServerPropertiesManager::AddServersData(
}
AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map);
- if (!AddToAlternativeServiceMap(server, *server_pref_dict,
+
+ // TODO(zhongyi): persist server's scheme/host/pair in a new version.
+ // Never call AddToAlternativeServiceMap for old versions disk data.
+ url::SchemeHostPort scheme_origin_pair("https", server.host(),
+ server.port());
+ if (version <= 4) {
+ DVLOG(1) << "Old version, won't update Alt-Svc from disck data";
+ }
+ if (!AddToAlternativeServiceMap(scheme_origin_pair, *server_pref_dict,
alternative_service_map) ||
!AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) {
return false;
@@ -681,7 +691,7 @@ bool HttpServerPropertiesManager::ParseAlternativeServiceDict(
}
bool HttpServerPropertiesManager::AddToAlternativeServiceMap(
- const HostPortPair& server,
+ const url::SchemeHostPort& server,
const base::DictionaryValue& server_pref_dict,
AlternativeServiceMap* alternative_service_map) {
DCHECK(alternative_service_map->Peek(server) ==
@@ -700,9 +710,10 @@ bool HttpServerPropertiesManager::AddToAlternativeServiceMap(
&alternative_service_dict))
return false;
AlternativeServiceInfo alternative_service_info;
- if (!ParseAlternativeServiceDict(*alternative_service_dict,
- server.ToString(),
- &alternative_service_info)) {
+ if (!ParseAlternativeServiceDict(
+ *alternative_service_dict,
+ HostPortPair::FromSchemeHostPort(server).ToString(),
+ &alternative_service_info)) {
return false;
}
if (base::Time::Now() < alternative_service_info.expiration) {
@@ -918,7 +929,7 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread(
// Maintain MRU order.
for (AlternativeServiceMap::const_reverse_iterator it = map.rbegin();
it != map.rend() && count < kMaxAlternateProtocolHostsToPersist; ++it) {
- const HostPortPair& server = it->first;
+ const url::SchemeHostPort& server = it->first;
AlternativeServiceInfoVector notbroken_alternative_service_info_vector;
for (const AlternativeServiceInfo& alternative_service_info : it->second) {
// Do not persist expired entries.
@@ -1068,7 +1079,8 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread(
for (AlternativeServiceMap::const_reverse_iterator map_it =
alternative_service_map->rbegin();
map_it != alternative_service_map->rend(); ++map_it) {
- const HostPortPair& server = map_it->first;
+ const HostPortPair& server =
+ HostPortPair::FromSchemeHostPort(map_it->first);
ServerPrefMap::iterator it = server_pref_map.Get(server);
if (it == server_pref_map.end()) {
ServerPref server_pref;
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698