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 873c8ca700faae8a9b1b39de9e47877d9000828b..5302437523c0e04440dac460615cd96ffffc5d03 100644 |
--- a/net/http/http_server_properties_manager.cc |
+++ b/net/http/http_server_properties_manager.cc |
@@ -172,41 +172,47 @@ bool HttpServerPropertiesManager::HasAlternateProtocol( |
return http_server_properties_impl_->HasAlternateProtocol(server); |
} |
-AlternateProtocolInfo HttpServerPropertiesManager::GetAlternateProtocol( |
- const HostPortPair& server) { |
+const net::AlternateProtocols& |
+HttpServerPropertiesManager::GetAlternateProtocols( |
+ const net::HostPortPair& server) { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
- return http_server_properties_impl_->GetAlternateProtocol(server); |
+ return http_server_properties_impl_->GetAlternateProtocols(server); |
} |
-void HttpServerPropertiesManager::SetAlternateProtocol( |
- const HostPortPair& server, |
+void HttpServerPropertiesManager::AddAlternateProtocol( |
+ const net::HostPortPair& server, |
uint16 alternate_port, |
AlternateProtocol alternate_protocol, |
double alternate_probability) { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
- http_server_properties_impl_->SetAlternateProtocol( |
+ http_server_properties_impl_->AddAlternateProtocol( |
server, alternate_port, alternate_protocol, alternate_probability); |
ScheduleUpdatePrefsOnNetworkThread(); |
} |
void HttpServerPropertiesManager::SetBrokenAlternateProtocol( |
- const HostPortPair& server) { |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& broken_alternate_protocol) { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
- http_server_properties_impl_->SetBrokenAlternateProtocol(server); |
+ http_server_properties_impl_->SetBrokenAlternateProtocol( |
+ server, broken_alternate_protocol); |
ScheduleUpdatePrefsOnNetworkThread(); |
} |
bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken( |
- const HostPortPair& server) { |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken( |
- server); |
+ server, alternate_protocol); |
} |
void HttpServerPropertiesManager::ConfirmAlternateProtocol( |
- const HostPortPair& server) { |
+ const HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
- http_server_properties_impl_->ConfirmAlternateProtocol(server); |
+ http_server_properties_impl_->ConfirmAlternateProtocol(server, |
+ alternate_protocol); |
ScheduleUpdatePrefsOnNetworkThread(); |
} |
@@ -217,6 +223,22 @@ void HttpServerPropertiesManager::ClearAlternateProtocol( |
ScheduleUpdatePrefsOnNetworkThread(); |
} |
+void HttpServerPropertiesManager::ClearNonBrokenAlternateProtocols( |
+ const net::HostPortPair& server) { |
+ DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
+ http_server_properties_impl_->ClearNonBrokenAlternateProtocols(server); |
+ ScheduleUpdatePrefsOnNetworkThread(); |
+} |
+ |
+void HttpServerPropertiesManager::RemoveAlternateProtocol( |
+ const net::HostPortPair& server, |
+ const AlternateProtocolInfo& alternate_protocol) { |
+ DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
+ http_server_properties_impl_->RemoveAlternateProtocol(server, |
+ alternate_protocol); |
+ ScheduleUpdatePrefsOnNetworkThread(); |
+} |
+ |
const AlternateProtocolMap& |
HttpServerPropertiesManager::alternate_protocol_map() const { |
DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
@@ -461,7 +483,8 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() { |
AlternateProtocolInfo port_alternate_protocol(static_cast<uint16>(port), |
protocol, probability); |
- alternate_protocol_map->Put(server, port_alternate_protocol); |
+ alternate_protocol_map->Put( |
+ server, AlternateProtocols(/*size=*/1, port_alternate_protocol)); |
} |
// Get SupportsQuic. |
@@ -652,28 +675,28 @@ void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread( |
} |
// A local or temporary data structure to hold |supports_spdy|, SpdySettings, |
-// AlternateProtocolInfo and SupportsQuic preferences for a server. This is used |
+// AlternateProtocols and SupportsQuic preferences for a server. This is used |
// only in UpdatePrefsOnPrefThread. |
struct ServerPref { |
ServerPref() |
: supports_spdy(false), |
settings_map(NULL), |
- alternate_protocol(NULL), |
+ alternate_protocols(NULL), |
supports_quic(NULL), |
server_network_stats(NULL) {} |
ServerPref(bool supports_spdy, |
const SettingsMap* settings_map, |
- const AlternateProtocolInfo* alternate_protocol, |
+ const AlternateProtocols* alternate_protocols, |
const SupportsQuic* supports_quic, |
const ServerNetworkStats* server_network_stats) |
: supports_spdy(supports_spdy), |
settings_map(settings_map), |
- alternate_protocol(alternate_protocol), |
+ alternate_protocols(alternate_protocols), |
supports_quic(supports_quic), |
server_network_stats(server_network_stats) {} |
bool supports_spdy; |
const SettingsMap* settings_map; |
- const AlternateProtocolInfo* alternate_protocol; |
+ const AlternateProtocols* alternate_protocols; |
const SupportsQuic* supports_quic; |
const ServerNetworkStats* server_network_stats; |
}; |
@@ -727,9 +750,18 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( |
alternate_protocol_map->begin(); |
map_it != alternate_protocol_map->end(); ++map_it) { |
const HostPortPair& server = map_it->first; |
- const AlternateProtocolInfo& port_alternate_protocol = map_it->second; |
- if (!IsAlternateProtocolValid(port_alternate_protocol.protocol)) { |
- continue; |
+ const AlternateProtocols alternate_protocols = map_it->second; |
+ AlternateProtocols::const_iterator alternate_protocol; |
+ for (alternate_protocol = alternate_protocols.begin(); |
+ alternate_protocol != alternate_protocols.end(); |
+ ++alternate_protocol) { |
+ if (!net::IsAlternateProtocolValid(alternate_protocol->protocol)) { |
+ break; |
+ } |
+ } |
+ // Do not add AlternateProtocols unless all of them have a valid protocol. |
+ if (alternate_protocol != alternate_protocols.end()) { |
+ break; |
} |
ServerPrefMap::iterator it = server_pref_map.find(server); |
@@ -737,7 +769,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( |
ServerPref server_pref(false, NULL, &map_it->second, NULL, NULL); |
server_pref_map[server] = server_pref; |
} else { |
- it->second.alternate_protocol = &map_it->second; |
+ it->second.alternate_protocols = &map_it->second; |
} |
} |
@@ -799,18 +831,19 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( |
} |
// Save alternate_protocol. |
- const AlternateProtocolInfo* port_alternate_protocol = |
- server_pref.alternate_protocol; |
- if (port_alternate_protocol && !port_alternate_protocol->is_broken) { |
+ if (server_pref.alternate_protocols && |
+ server_pref.alternate_protocols->size() >= 1) { |
base::DictionaryValue* port_alternate_protocol_dict = |
new base::DictionaryValue; |
+ const net::AlternateProtocolInfo& port_alternate_protocol = |
+ server_pref.alternate_protocols->at(0); |
port_alternate_protocol_dict->SetInteger("port", |
- port_alternate_protocol->port); |
+ port_alternate_protocol.port); |
const char* protocol_str = |
- AlternateProtocolToString(port_alternate_protocol->protocol); |
+ AlternateProtocolToString(port_alternate_protocol.protocol); |
port_alternate_protocol_dict->SetString("protocol_str", protocol_str); |
port_alternate_protocol_dict->SetDouble( |
- "probability", port_alternate_protocol->probability); |
+ "probability", port_alternate_protocol.probability); |
server_pref_dict->SetWithoutPathExpansion( |
"alternate_protocol", port_alternate_protocol_dict); |
} |