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

Unified Diff: net/http/http_server_properties_manager.cc

Issue 1878143005: SHP 4: Change AlternativeServiceMap to use SchemeHostPort as the key. No change to Pref data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SHP_3
Patch Set: fix cronet && SpdyNetworkTransactionUnittests 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
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 f6a121b0acb1510a4ca4f614c91931fa2f0b167a..397635f007838fd9ad30e51874460b09a147d638 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -189,13 +189,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());
@@ -208,7 +208,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(
@@ -264,7 +264,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();
@@ -553,11 +553,10 @@ bool HttpServerPropertiesManager::AddServersData(
// to SchemeHostPort.
// Get server's host/pair.
const std::string& server_str = it.key();
- HostPortPair server = HostPortPair::FromString(server_str);
// TODO(zhongyi): fill in the scheme field when servers_dict has scheme.
std::string spdy_server_url = "https://" + server_str;
url::SchemeHostPort spdy_server((GURL(spdy_server_url)));
- if (server.host().empty()) {
+ if (spdy_server.host().empty()) {
DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
return false;
}
@@ -576,7 +575,7 @@ bool HttpServerPropertiesManager::AddServersData(
}
AddToSpdySettingsMap(spdy_server, *server_pref_dict, spdy_settings_map);
- if (!AddToAlternativeServiceMap(server, *server_pref_dict,
+ if (!AddToAlternativeServiceMap(spdy_server, *server_pref_dict,
alternative_service_map) ||
!AddToNetworkStatsMap(spdy_server, *server_pref_dict,
network_stats_map)) {
@@ -689,7 +688,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) ==
@@ -709,7 +708,7 @@ bool HttpServerPropertiesManager::AddToAlternativeServiceMap(
return false;
AlternativeServiceInfo alternative_service_info;
if (!ParseAlternativeServiceDict(*alternative_service_dict,
- server.ToString(),
+ server.Serialize(),
&alternative_service_info)) {
return false;
}
@@ -926,7 +925,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.
@@ -1078,7 +1077,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;
+ // TODO(zhongyi): migrate to SHP once server_pref_map is migrated.
+ const HostPortPair server(map_it->first.host(), map_it->first.port());
ServerPrefMap::iterator it = server_pref_map.Get(server);
if (it == server_pref_map.end()) {
ServerPref server_pref;

Powered by Google App Engine
This is Rietveld 408576698