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

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: Add unittests Created 4 years, 9 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 f8d133c91b0bd3fda6dd03c1c4392e1f7eb08c4a..0c0c1dcf400dec9882fd620ed02b8ab4f5398991 100644
--- a/net/http/http_server_properties_manager.cc
+++ b/net/http/http_server_properties_manager.cc
@@ -146,7 +146,7 @@ void HttpServerPropertiesManager::Clear(const base::Closure& completion) {
}
bool HttpServerPropertiesManager::SupportsRequestPriority(
- const HostPortPair& server) {
+ const SchemeOriginPair& server) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
return http_server_properties_impl_->SupportsRequestPriority(server);
}
@@ -187,13 +187,13 @@ void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server,
}
AlternativeServiceVector HttpServerPropertiesManager::GetAlternativeServices(
- const HostPortPair& origin) {
+ const SchemeOriginPair& origin) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
return http_server_properties_impl_->GetAlternativeServices(origin);
}
bool HttpServerPropertiesManager::SetAlternativeService(
- const HostPortPair& origin,
+ const SchemeOriginPair& origin,
const AlternativeService& alternative_service,
double alternative_probability,
base::Time expiration) {
@@ -207,7 +207,7 @@ bool HttpServerPropertiesManager::SetAlternativeService(
}
bool HttpServerPropertiesManager::SetAlternativeServices(
- const HostPortPair& origin,
+ const SchemeOriginPair& origin,
const AlternativeServiceInfoVector& alternative_service_info_vector) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
const bool changed = http_server_properties_impl_->SetAlternativeServices(
@@ -263,7 +263,7 @@ void HttpServerPropertiesManager::ConfirmAlternativeService(
}
void HttpServerPropertiesManager::ClearAlternativeServices(
- const HostPortPair& origin) {
+ const SchemeOriginPair& origin) {
DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
const AlternativeServiceMap& map =
http_server_properties_impl_->alternative_service_map();
@@ -559,6 +559,8 @@ bool HttpServerPropertiesManager::AddServersData(
// Get server's host/pair.
const std::string& server_str = it.key();
HostPortPair server = HostPortPair::FromString(server_str);
+ // TODO(zhongyi): figure out which scheme is using.
+ SchemeOriginPair scheme_origin_pair("https", server);
Zhongyi Shi 2016/03/22 20:49:08 I'm not sure, whether setting the scheme to be "ht
Ryan Hamilton 2016/03/24 22:23:14 I recommend chatting with Raman about this. He's t
Zhongyi Shi 2016/04/04 18:58:36 After chatting with Raman and a deep digging in th
if (server.host().empty()) {
DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
return false;
@@ -578,7 +580,7 @@ bool HttpServerPropertiesManager::AddServersData(
}
AddToSpdySettingsMap(server, *server_pref_dict, spdy_settings_map);
- if (!AddToAlternativeServiceMap(server, *server_pref_dict,
+ if (!AddToAlternativeServiceMap(scheme_origin_pair, *server_pref_dict,
alternative_service_map) ||
!AddToNetworkStatsMap(server, *server_pref_dict, network_stats_map)) {
return false;
@@ -700,7 +702,7 @@ bool HttpServerPropertiesManager::ParseAlternativeServiceDict(
}
bool HttpServerPropertiesManager::AddToAlternativeServiceMap(
- const HostPortPair& server,
+ const SchemeOriginPair& server,
const base::DictionaryValue& server_pref_dict,
AlternativeServiceMap* alternative_service_map) {
DCHECK(alternative_service_map->Peek(server) ==
@@ -720,7 +722,7 @@ bool HttpServerPropertiesManager::AddToAlternativeServiceMap(
return false;
AlternativeServiceInfo alternative_service_info;
if (!ParseAlternativeServiceDict(*alternative_service_dict,
- server.ToString(),
+ server.host_port_pair().ToString(),
&alternative_service_info)) {
return false;
}
@@ -937,7 +939,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 SchemeOriginPair& server = it->first;
AlternativeServiceInfoVector notbroken_alternative_service_info_vector;
for (const AlternativeServiceInfo& alternative_service_info : it->second) {
// Do not persist expired entries.
@@ -1087,7 +1089,7 @@ 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 = map_it->first.host_port_pair();
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