| 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..20a2703b735e636185d7bc04ea07b15ae61fffab 100644
|
| --- a/net/http/http_server_properties_manager.cc
|
| +++ b/net/http/http_server_properties_manager.cc
|
| @@ -146,14 +146,13 @@ void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server,
|
| ScheduleUpdatePrefsOnNetworkThread();
|
| }
|
|
|
| -bool HttpServerPropertiesManager::RequiresHTTP11(
|
| - const net::HostPortPair& server) {
|
| +bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) {
|
| DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
| return http_server_properties_impl_->RequiresHTTP11(server);
|
| }
|
|
|
| void HttpServerPropertiesManager::SetHTTP11Required(
|
| - const net::HostPortPair& server) {
|
| + const HostPortPair& server) {
|
| DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
|
|
| http_server_properties_impl_->SetHTTP11Required(server);
|
| @@ -172,41 +171,46 @@ bool HttpServerPropertiesManager::HasAlternateProtocol(
|
| return http_server_properties_impl_->HasAlternateProtocol(server);
|
| }
|
|
|
| -AlternateProtocolInfo HttpServerPropertiesManager::GetAlternateProtocol(
|
| +const AlternateProtocols& HttpServerPropertiesManager::GetAlternateProtocols(
|
| const HostPortPair& server) {
|
| DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
| - return http_server_properties_impl_->GetAlternateProtocol(server);
|
| + return http_server_properties_impl_->GetAlternateProtocols(server);
|
| }
|
|
|
| -void HttpServerPropertiesManager::SetAlternateProtocol(
|
| +void HttpServerPropertiesManager::AddAlternateProtocol(
|
| const 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 +221,22 @@ void HttpServerPropertiesManager::ClearAlternateProtocol(
|
| ScheduleUpdatePrefsOnNetworkThread();
|
| }
|
|
|
| +void HttpServerPropertiesManager::ClearNonBrokenAlternateProtocols(
|
| + const HostPortPair& server) {
|
| + DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
| + http_server_properties_impl_->ClearNonBrokenAlternateProtocols(server);
|
| + ScheduleUpdatePrefsOnNetworkThread();
|
| +}
|
| +
|
| +void HttpServerPropertiesManager::RemoveAlternateProtocol(
|
| + const 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 +481,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 +673,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,8 +748,17 @@ 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)) {
|
| + 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 (!IsAlternateProtocolValid(alternate_protocol->protocol)) {
|
| + break;
|
| + }
|
| + }
|
| + // Do not add AlternateProtocols unless all of them have a valid protocol.
|
| + if (alternate_protocol != alternate_protocols.end()) {
|
| continue;
|
| }
|
|
|
| @@ -737,7 +767,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 +829,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 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);
|
| }
|
|
|