| 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 6796fb19fd8fbb36238da08a9a84f9f808e0ac97..2217d370c63f5fd1bf3b45f1fb4756b5088b721f 100644
|
| --- a/net/http/http_server_properties_manager.cc
|
| +++ b/net/http/http_server_properties_manager.cc
|
| @@ -157,42 +157,46 @@ bool HttpServerPropertiesManager::HasAlternateProtocol(
|
| return http_server_properties_impl_->HasAlternateProtocol(server);
|
| }
|
|
|
| -net::AlternateProtocolInfo
|
| -HttpServerPropertiesManager::GetAlternateProtocol(
|
| +net::AlternateProtocols HttpServerPropertiesManager::GetAlternateProtocol(
|
| const net::HostPortPair& server) {
|
| DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
| return http_server_properties_impl_->GetAlternateProtocol(server);
|
| }
|
|
|
| -void HttpServerPropertiesManager::SetAlternateProtocol(
|
| +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 net::HostPortPair& server) {
|
| + const net::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 net::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 net::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();
|
| }
|
|
|
| @@ -203,6 +207,15 @@ void HttpServerPropertiesManager::ClearAlternateProtocol(
|
| 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 net::AlternateProtocolMap&
|
| HttpServerPropertiesManager::alternate_protocol_map() const {
|
| DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
|
| @@ -451,7 +464,10 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread() {
|
| net::AlternateProtocolInfo port_alternate_protocol(port,
|
| protocol,
|
| probability);
|
| - alternate_protocol_map->Put(server, port_alternate_protocol);
|
| + alternate_protocol_map->Put(
|
| + server,
|
| + AlternateProtocols(/* size = */ 1,
|
| + /* val = */ port_alternate_protocol));
|
| ++count;
|
| } while (false);
|
|
|
| @@ -615,24 +631,24 @@ 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) {}
|
| ServerPref(bool supports_spdy,
|
| const net::SettingsMap* settings_map,
|
| - const net::AlternateProtocolInfo* alternate_protocol,
|
| + const net::AlternateProtocols* alternate_protocols,
|
| const net::SupportsQuic* supports_quic)
|
| : supports_spdy(supports_spdy),
|
| settings_map(settings_map),
|
| - alternate_protocol(alternate_protocol),
|
| + alternate_protocols(alternate_protocols),
|
| supports_quic(supports_quic) {}
|
| bool supports_spdy;
|
| const net::SettingsMap* settings_map;
|
| - const net::AlternateProtocolInfo* alternate_protocol;
|
| + const net::AlternateProtocols* alternate_protocols;
|
| const net::SupportsQuic* supports_quic;
|
| };
|
|
|
| @@ -686,10 +702,18 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread(
|
| map_it != alternate_protocol_map->end();
|
| ++map_it) {
|
| const net::HostPortPair& server = map_it->first;
|
| - const net::AlternateProtocolInfo& port_alternate_protocol =
|
| - map_it->second;
|
| - if (!net::IsAlternateProtocolValid(port_alternate_protocol.protocol)) {
|
| - continue;
|
| + const net::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);
|
| @@ -697,7 +721,7 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread(
|
| ServerPref server_pref(false, NULL, &map_it->second, NULL);
|
| server_pref_map[server] = server_pref;
|
| } else {
|
| - it->second.alternate_protocol = &map_it->second;
|
| + it->second.alternate_protocols = &map_it->second;
|
| }
|
| }
|
|
|
| @@ -746,18 +770,19 @@ void HttpServerPropertiesManager::UpdatePrefsOnPrefThread(
|
| }
|
|
|
| // Save alternate_protocol.
|
| - if (server_pref.alternate_protocol) {
|
| + 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_protocol;
|
| + 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 =
|
| - net::AlternateProtocolToString(port_alternate_protocol->protocol);
|
| + net::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);
|
| }
|
|
|