Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_server_properties_manager.h" | 5 #include "net/http/http_server_properties_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 139 } |
| 140 | 140 |
| 141 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, | 141 void HttpServerPropertiesManager::SetSupportsSpdy(const HostPortPair& server, |
| 142 bool support_spdy) { | 142 bool support_spdy) { |
| 143 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 143 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 144 | 144 |
| 145 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); | 145 http_server_properties_impl_->SetSupportsSpdy(server, support_spdy); |
| 146 ScheduleUpdatePrefsOnNetworkThread(); | 146 ScheduleUpdatePrefsOnNetworkThread(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool HttpServerPropertiesManager::RequiresHTTP11( | 149 bool HttpServerPropertiesManager::RequiresHTTP11(const HostPortPair& server) { |
| 150 const net::HostPortPair& server) { | |
| 151 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 150 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 152 return http_server_properties_impl_->RequiresHTTP11(server); | 151 return http_server_properties_impl_->RequiresHTTP11(server); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void HttpServerPropertiesManager::SetHTTP11Required( | 154 void HttpServerPropertiesManager::SetHTTP11Required( |
| 156 const net::HostPortPair& server) { | 155 const HostPortPair& server) { |
| 157 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 156 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 158 | 157 |
| 159 http_server_properties_impl_->SetHTTP11Required(server); | 158 http_server_properties_impl_->SetHTTP11Required(server); |
| 160 ScheduleUpdatePrefsOnNetworkThread(); | 159 ScheduleUpdatePrefsOnNetworkThread(); |
| 161 } | 160 } |
| 162 | 161 |
| 163 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, | 162 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, |
| 164 SSLConfig* ssl_config) { | 163 SSLConfig* ssl_config) { |
| 165 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 164 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 166 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); | 165 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); |
| 167 } | 166 } |
| 168 | 167 |
| 169 bool HttpServerPropertiesManager::HasAlternateProtocol( | 168 bool HttpServerPropertiesManager::HasAlternateProtocol( |
| 170 const HostPortPair& server) { | 169 const HostPortPair& server) { |
| 171 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 170 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 172 return http_server_properties_impl_->HasAlternateProtocol(server); | 171 return http_server_properties_impl_->HasAlternateProtocol(server); |
| 173 } | 172 } |
| 174 | 173 |
| 175 AlternateProtocolInfo HttpServerPropertiesManager::GetAlternateProtocol( | 174 const AlternateProtocols& HttpServerPropertiesManager::GetAlternateProtocols( |
| 176 const HostPortPair& server) { | 175 const HostPortPair& server) { |
| 177 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 176 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 178 return http_server_properties_impl_->GetAlternateProtocol(server); | 177 return http_server_properties_impl_->GetAlternateProtocols(server); |
| 179 } | 178 } |
| 180 | 179 |
| 181 void HttpServerPropertiesManager::SetAlternateProtocol( | 180 void HttpServerPropertiesManager::AddAlternateProtocol( |
| 182 const HostPortPair& server, | 181 const HostPortPair& server, |
| 183 uint16 alternate_port, | 182 uint16 alternate_port, |
| 184 AlternateProtocol alternate_protocol, | 183 AlternateProtocol alternate_protocol, |
| 185 double alternate_probability) { | 184 double alternate_probability) { |
| 186 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 185 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 187 http_server_properties_impl_->SetAlternateProtocol( | 186 http_server_properties_impl_->AddAlternateProtocol( |
| 188 server, alternate_port, alternate_protocol, alternate_probability); | 187 server, alternate_port, alternate_protocol, alternate_probability); |
| 189 ScheduleUpdatePrefsOnNetworkThread(); | 188 ScheduleUpdatePrefsOnNetworkThread(); |
| 190 } | 189 } |
| 191 | 190 |
| 192 void HttpServerPropertiesManager::SetBrokenAlternateProtocol( | 191 void HttpServerPropertiesManager::SetBrokenAlternateProtocol( |
| 193 const HostPortPair& server) { | 192 const HostPortPair& server, |
| 193 const AlternateProtocolInfo& broken_alternate_protocol) { | |
| 194 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 194 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 195 http_server_properties_impl_->SetBrokenAlternateProtocol(server); | 195 http_server_properties_impl_->SetBrokenAlternateProtocol( |
| 196 server, broken_alternate_protocol); | |
| 196 ScheduleUpdatePrefsOnNetworkThread(); | 197 ScheduleUpdatePrefsOnNetworkThread(); |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken( | 200 bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken( |
| 200 const HostPortPair& server) { | 201 const HostPortPair& server, |
| 202 const AlternateProtocolInfo& alternate_protocol) { | |
| 201 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 203 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 202 return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken( | 204 return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken( |
| 203 server); | 205 server, alternate_protocol); |
| 204 } | 206 } |
| 205 | 207 |
| 206 void HttpServerPropertiesManager::ConfirmAlternateProtocol( | 208 void HttpServerPropertiesManager::ConfirmAlternateProtocol( |
| 207 const HostPortPair& server) { | 209 const HostPortPair& server, |
| 210 const AlternateProtocolInfo& alternate_protocol) { | |
| 208 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 211 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 209 http_server_properties_impl_->ConfirmAlternateProtocol(server); | 212 http_server_properties_impl_->ConfirmAlternateProtocol(server, |
| 213 alternate_protocol); | |
| 210 ScheduleUpdatePrefsOnNetworkThread(); | 214 ScheduleUpdatePrefsOnNetworkThread(); |
| 211 } | 215 } |
| 212 | 216 |
| 213 void HttpServerPropertiesManager::ClearAlternateProtocol( | 217 void HttpServerPropertiesManager::ClearAlternateProtocol( |
| 214 const HostPortPair& server) { | 218 const HostPortPair& server) { |
| 215 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 219 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 216 http_server_properties_impl_->ClearAlternateProtocol(server); | 220 http_server_properties_impl_->ClearAlternateProtocol(server); |
| 217 ScheduleUpdatePrefsOnNetworkThread(); | 221 ScheduleUpdatePrefsOnNetworkThread(); |
| 218 } | 222 } |
| 219 | 223 |
| 224 void HttpServerPropertiesManager::ClearNonBrokenAlternateProtocols( | |
| 225 const HostPortPair& server) { | |
| 226 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | |
| 227 http_server_properties_impl_->ClearNonBrokenAlternateProtocols(server); | |
| 228 ScheduleUpdatePrefsOnNetworkThread(); | |
| 229 } | |
| 230 | |
| 231 void HttpServerPropertiesManager::RemoveAlternateProtocol( | |
| 232 const HostPortPair& server, | |
| 233 const AlternateProtocolInfo& alternate_protocol) { | |
| 234 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | |
| 235 http_server_properties_impl_->RemoveAlternateProtocol(server, | |
| 236 alternate_protocol); | |
| 237 ScheduleUpdatePrefsOnNetworkThread(); | |
| 238 } | |
| 239 | |
| 220 const AlternateProtocolMap& | 240 const AlternateProtocolMap& |
| 221 HttpServerPropertiesManager::alternate_protocol_map() const { | 241 HttpServerPropertiesManager::alternate_protocol_map() const { |
| 222 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 242 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 223 return http_server_properties_impl_->alternate_protocol_map(); | 243 return http_server_properties_impl_->alternate_protocol_map(); |
| 224 } | 244 } |
| 225 | 245 |
| 226 void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold( | 246 void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold( |
| 227 double threshold) { | 247 double threshold) { |
| 228 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 248 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
| 229 http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold( | 249 http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold( |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 << server_str; | 435 << server_str; |
| 416 NOTREACHED(); | 436 NOTREACHED(); |
| 417 continue; | 437 continue; |
| 418 } | 438 } |
| 419 SettingsFlagsAndValue flags_and_value(SETTINGS_FLAG_PERSISTED, value); | 439 SettingsFlagsAndValue flags_and_value(SETTINGS_FLAG_PERSISTED, value); |
| 420 settings_map[static_cast<SpdySettingsIds>(id)] = flags_and_value; | 440 settings_map[static_cast<SpdySettingsIds>(id)] = flags_and_value; |
| 421 } | 441 } |
| 422 spdy_settings_map->Put(server, settings_map); | 442 spdy_settings_map->Put(server, settings_map); |
| 423 } | 443 } |
| 424 | 444 |
| 425 // Get alternate_protocol server. | 445 // Get alternative_services... |
| 426 DCHECK(alternate_protocol_map->Peek(server) == | 446 DCHECK(alternate_protocol_map->Peek(server) == |
| 427 alternate_protocol_map->end()); | 447 alternate_protocol_map->end()); |
| 428 const base::DictionaryValue* port_alternate_protocol_dict = NULL; | 448 const base::ListValue* alternate_protocol_list = NULL; |
| 429 if (server_pref_dict->GetDictionaryWithoutPathExpansion( | 449 if (server_pref_dict->GetListWithoutPathExpansion( |
| 430 "alternate_protocol", &port_alternate_protocol_dict)) { | 450 "alternative_services", &alternate_protocol_list) && |
| 431 int port = 0; | 451 !alternate_protocol_list->empty()) { |
| 432 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | 452 AlternateProtocols alternate_protocols; |
| 433 "port", &port) || | 453 for (const auto& alternate_protocol_list_item : |
| 434 !IsPortValid(port)) { | 454 *alternate_protocol_list) { |
| 435 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 455 base::DictionaryValue* alternate_protocol_dict; |
| 436 detected_corrupted_prefs = true; | 456 if (!alternate_protocol_list_item->GetAsDictionary( |
| 437 continue; | 457 &alternate_protocol_dict)) |
| 458 continue; | |
| 459 AlternateProtocolInfo alternate_protocol; | |
| 460 | |
| 461 int port = 0; | |
| 462 if (!alternate_protocol_dict->GetInteger("port", &port) || | |
| 463 !IsPortValid(port)) { | |
| 464 DVLOG(1) << "Malformed AltSvc port for server: " << server_str; | |
| 465 detected_corrupted_prefs = true; | |
| 466 continue; | |
| 467 } | |
| 468 alternate_protocol.port = static_cast<uint16>(port); | |
| 469 | |
| 470 std::string protocol_str; | |
| 471 if (!alternate_protocol_dict->GetStringWithoutPathExpansion( | |
| 472 "protocol_str", &protocol_str)) { | |
| 473 DVLOG(1) << "Malformed AltSvc protocol string for server: " | |
| 474 << server_str; | |
| 475 detected_corrupted_prefs = true; | |
| 476 continue; | |
| 477 } | |
| 478 AlternateProtocol protocol = AlternateProtocolFromString(protocol_str); | |
| 479 if (!IsAlternateProtocolValid(protocol)) { | |
| 480 DVLOG(1) << "Invalid AltSvc protocol string for server: " | |
| 481 << server_str; | |
| 482 detected_corrupted_prefs = true; | |
| 483 continue; | |
| 484 } | |
| 485 alternate_protocol.protocol = AlternateProtocolFromString(protocol_str); | |
| 486 | |
| 487 double probability = 1; | |
| 488 if (alternate_protocol_dict->HasKey("probability") && | |
| 489 !alternate_protocol_dict->GetDoubleWithoutPathExpansion( | |
| 490 "probability", &probability)) { | |
| 491 DVLOG(1) << "Malformed AltSvc probability for server: " << server_str; | |
| 492 detected_corrupted_prefs = true; | |
| 493 continue; | |
| 494 } | |
| 495 alternate_protocol.probability = probability; | |
| 496 | |
| 497 alternate_protocols.push_back(alternate_protocol); | |
| 438 } | 498 } |
| 439 std::string protocol_str; | 499 alternate_protocol_map->Put(server, alternate_protocols); |
| 440 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( | 500 } else { |
| 441 "protocol_str", &protocol_str)) { | 501 // ...or alternate_protocol. |
|
Bence
2015/01/30 21:24:50
Do we need to be able to load old settings, or can
Ryan Hamilton
2015/01/30 21:50:19
We definitely want to support old settings. It loo
Bence
2015/02/06 19:59:40
Done.
| |
| 442 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 502 const base::DictionaryValue* port_alternate_protocol_dict = NULL; |
| 443 detected_corrupted_prefs = true; | 503 if (server_pref_dict->GetDictionaryWithoutPathExpansion( |
| 444 continue; | 504 "alternate_protocol", &port_alternate_protocol_dict)) { |
| 505 int port = 0; | |
| 506 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | |
| 507 "port", &port) || | |
| 508 !IsPortValid(port)) { | |
| 509 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 510 detected_corrupted_prefs = true; | |
| 511 continue; | |
| 512 } | |
| 513 std::string protocol_str; | |
| 514 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( | |
| 515 "protocol_str", &protocol_str)) { | |
| 516 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 517 detected_corrupted_prefs = true; | |
| 518 continue; | |
| 519 } | |
| 520 AlternateProtocol protocol = AlternateProtocolFromString(protocol_str); | |
| 521 if (!IsAlternateProtocolValid(protocol)) { | |
| 522 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 523 detected_corrupted_prefs = true; | |
| 524 continue; | |
| 525 } | |
| 526 | |
| 527 double probability = 1; | |
| 528 if (port_alternate_protocol_dict->HasKey("probability") && | |
| 529 !port_alternate_protocol_dict->GetDoubleWithoutPathExpansion( | |
| 530 "probability", &probability)) { | |
| 531 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 532 detected_corrupted_prefs = true; | |
| 533 continue; | |
| 534 } | |
| 535 | |
| 536 AlternateProtocolInfo port_alternate_protocol(static_cast<uint16>(port), | |
| 537 protocol, probability); | |
| 538 alternate_protocol_map->Put( | |
| 539 server, AlternateProtocols(/*size=*/1, port_alternate_protocol)); | |
| 445 } | 540 } |
| 446 AlternateProtocol protocol = AlternateProtocolFromString(protocol_str); | |
| 447 if (!IsAlternateProtocolValid(protocol)) { | |
| 448 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 449 detected_corrupted_prefs = true; | |
| 450 continue; | |
| 451 } | |
| 452 | |
| 453 double probability = 1; | |
| 454 if (port_alternate_protocol_dict->HasKey("probability") && | |
| 455 !port_alternate_protocol_dict->GetDoubleWithoutPathExpansion( | |
| 456 "probability", &probability)) { | |
| 457 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | |
| 458 detected_corrupted_prefs = true; | |
| 459 continue; | |
| 460 } | |
| 461 | |
| 462 AlternateProtocolInfo port_alternate_protocol(static_cast<uint16>(port), | |
| 463 protocol, probability); | |
| 464 alternate_protocol_map->Put(server, port_alternate_protocol); | |
| 465 } | 541 } |
| 466 | 542 |
| 467 // Get SupportsQuic. | 543 // Get SupportsQuic. |
| 468 DCHECK(supports_quic_map->find(server) == supports_quic_map->end()); | 544 DCHECK(supports_quic_map->find(server) == supports_quic_map->end()); |
| 469 const base::DictionaryValue* supports_quic_dict = NULL; | 545 const base::DictionaryValue* supports_quic_dict = NULL; |
| 470 if (server_pref_dict->GetDictionaryWithoutPathExpansion( | 546 if (server_pref_dict->GetDictionaryWithoutPathExpansion( |
| 471 "supports_quic", &supports_quic_dict)) { | 547 "supports_quic", &supports_quic_dict)) { |
| 472 bool used_quic = 0; | 548 bool used_quic = 0; |
| 473 if (!supports_quic_dict->GetBooleanWithoutPathExpansion( | 549 if (!supports_quic_dict->GetBooleanWithoutPathExpansion( |
| 474 "used_quic", &used_quic)) { | 550 "used_quic", &used_quic)) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 pref_task_runner_->PostTask( | 721 pref_task_runner_->PostTask( |
| 646 FROM_HERE, | 722 FROM_HERE, |
| 647 base::Bind( | 723 base::Bind( |
| 648 &HttpServerPropertiesManager::UpdatePrefsOnPrefThread, pref_weak_ptr_, | 724 &HttpServerPropertiesManager::UpdatePrefsOnPrefThread, pref_weak_ptr_, |
| 649 base::Owned(spdy_server_list), base::Owned(spdy_settings_map), | 725 base::Owned(spdy_server_list), base::Owned(spdy_settings_map), |
| 650 base::Owned(alternate_protocol_map), base::Owned(supports_quic_map), | 726 base::Owned(alternate_protocol_map), base::Owned(supports_quic_map), |
| 651 base::Owned(server_network_stats_map), completion)); | 727 base::Owned(server_network_stats_map), completion)); |
| 652 } | 728 } |
| 653 | 729 |
| 654 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, | 730 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, |
| 655 // AlternateProtocolInfo and SupportsQuic preferences for a server. This is used | 731 // AlternateProtocols and SupportsQuic preferences for a server. This is used |
| 656 // only in UpdatePrefsOnPrefThread. | 732 // only in UpdatePrefsOnPrefThread. |
| 657 struct ServerPref { | 733 struct ServerPref { |
| 658 ServerPref() | 734 ServerPref() |
| 659 : supports_spdy(false), | 735 : supports_spdy(false), |
| 660 settings_map(NULL), | 736 settings_map(NULL), |
| 661 alternate_protocol(NULL), | 737 alternate_protocols(NULL), |
| 662 supports_quic(NULL), | 738 supports_quic(NULL), |
| 663 server_network_stats(NULL) {} | 739 server_network_stats(NULL) {} |
| 664 ServerPref(bool supports_spdy, | 740 ServerPref(bool supports_spdy, |
| 665 const SettingsMap* settings_map, | 741 const SettingsMap* settings_map, |
| 666 const AlternateProtocolInfo* alternate_protocol, | 742 const AlternateProtocols* alternate_protocols, |
| 667 const SupportsQuic* supports_quic, | 743 const SupportsQuic* supports_quic, |
| 668 const ServerNetworkStats* server_network_stats) | 744 const ServerNetworkStats* server_network_stats) |
| 669 : supports_spdy(supports_spdy), | 745 : supports_spdy(supports_spdy), |
| 670 settings_map(settings_map), | 746 settings_map(settings_map), |
| 671 alternate_protocol(alternate_protocol), | 747 alternate_protocols(alternate_protocols), |
| 672 supports_quic(supports_quic), | 748 supports_quic(supports_quic), |
| 673 server_network_stats(server_network_stats) {} | 749 server_network_stats(server_network_stats) {} |
| 674 bool supports_spdy; | 750 bool supports_spdy; |
| 675 const SettingsMap* settings_map; | 751 const SettingsMap* settings_map; |
| 676 const AlternateProtocolInfo* alternate_protocol; | 752 const AlternateProtocols* alternate_protocols; |
| 677 const SupportsQuic* supports_quic; | 753 const SupportsQuic* supports_quic; |
| 678 const ServerNetworkStats* server_network_stats; | 754 const ServerNetworkStats* server_network_stats; |
| 679 }; | 755 }; |
| 680 | 756 |
| 681 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( | 757 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( |
| 682 base::ListValue* spdy_server_list, | 758 base::ListValue* spdy_server_list, |
| 683 SpdySettingsMap* spdy_settings_map, | 759 SpdySettingsMap* spdy_settings_map, |
| 684 AlternateProtocolMap* alternate_protocol_map, | 760 AlternateProtocolMap* alternate_protocol_map, |
| 685 SupportsQuicMap* supports_quic_map, | 761 SupportsQuicMap* supports_quic_map, |
| 686 ServerNetworkStatsMap* server_network_stats_map, | 762 ServerNetworkStatsMap* server_network_stats_map, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 } else { | 796 } else { |
| 721 it->second.settings_map = &map_it->second; | 797 it->second.settings_map = &map_it->second; |
| 722 } | 798 } |
| 723 } | 799 } |
| 724 | 800 |
| 725 // Add AlternateProtocol servers to server_pref_map. | 801 // Add AlternateProtocol servers to server_pref_map. |
| 726 for (AlternateProtocolMap::const_iterator map_it = | 802 for (AlternateProtocolMap::const_iterator map_it = |
| 727 alternate_protocol_map->begin(); | 803 alternate_protocol_map->begin(); |
| 728 map_it != alternate_protocol_map->end(); ++map_it) { | 804 map_it != alternate_protocol_map->end(); ++map_it) { |
| 729 const HostPortPair& server = map_it->first; | 805 const HostPortPair& server = map_it->first; |
| 730 const AlternateProtocolInfo& port_alternate_protocol = map_it->second; | |
| 731 if (!IsAlternateProtocolValid(port_alternate_protocol.protocol)) { | |
| 732 continue; | |
| 733 } | |
| 734 | |
| 735 ServerPrefMap::iterator it = server_pref_map.find(server); | 806 ServerPrefMap::iterator it = server_pref_map.find(server); |
| 736 if (it == server_pref_map.end()) { | 807 if (it == server_pref_map.end()) { |
| 737 ServerPref server_pref(false, NULL, &map_it->second, NULL, NULL); | 808 ServerPref server_pref(false, NULL, &map_it->second, NULL, NULL); |
| 738 server_pref_map[server] = server_pref; | 809 server_pref_map[server] = server_pref; |
| 739 } else { | 810 } else { |
| 740 it->second.alternate_protocol = &map_it->second; | 811 it->second.alternate_protocols = &map_it->second; |
| 741 } | 812 } |
| 742 } | 813 } |
| 743 | 814 |
| 744 // Add SupportsQuic servers to server_pref_map. | 815 // Add SupportsQuic servers to server_pref_map. |
| 745 for (SupportsQuicMap::const_iterator map_it = supports_quic_map->begin(); | 816 for (SupportsQuicMap::const_iterator map_it = supports_quic_map->begin(); |
| 746 map_it != supports_quic_map->end(); ++map_it) { | 817 map_it != supports_quic_map->end(); ++map_it) { |
| 747 const HostPortPair& server = map_it->first; | 818 const HostPortPair& server = map_it->first; |
| 748 | 819 |
| 749 ServerPrefMap::iterator it = server_pref_map.find(server); | 820 ServerPrefMap::iterator it = server_pref_map.find(server); |
| 750 if (it == server_pref_map.end()) { | 821 if (it == server_pref_map.end()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 for (SettingsMap::const_iterator it = server_pref.settings_map->begin(); | 862 for (SettingsMap::const_iterator it = server_pref.settings_map->begin(); |
| 792 it != server_pref.settings_map->end(); ++it) { | 863 it != server_pref.settings_map->end(); ++it) { |
| 793 SpdySettingsIds id = it->first; | 864 SpdySettingsIds id = it->first; |
| 794 uint32 value = it->second.second; | 865 uint32 value = it->second.second; |
| 795 std::string key = base::StringPrintf("%u", id); | 866 std::string key = base::StringPrintf("%u", id); |
| 796 spdy_settings_dict->SetInteger(key, value); | 867 spdy_settings_dict->SetInteger(key, value); |
| 797 } | 868 } |
| 798 server_pref_dict->SetWithoutPathExpansion("settings", spdy_settings_dict); | 869 server_pref_dict->SetWithoutPathExpansion("settings", spdy_settings_dict); |
| 799 } | 870 } |
| 800 | 871 |
| 801 // Save alternate_protocol. | 872 // Save alternative_services. |
| 802 const AlternateProtocolInfo* port_alternate_protocol = | 873 if (server_pref.alternate_protocols && |
| 803 server_pref.alternate_protocol; | 874 server_pref.alternate_protocols->size() > 0) { |
| 804 if (port_alternate_protocol && !port_alternate_protocol->is_broken) { | 875 base::ListValue* alternate_protocols_list = new base::ListValue; |
| 805 base::DictionaryValue* port_alternate_protocol_dict = | 876 for (AlternateProtocols::const_iterator alternate_protocol = |
| 806 new base::DictionaryValue; | 877 server_pref.alternate_protocols->begin(); |
| 807 port_alternate_protocol_dict->SetInteger("port", | 878 alternate_protocol != server_pref.alternate_protocols->end(); |
| 808 port_alternate_protocol->port); | 879 ++alternate_protocol) { |
| 809 const char* protocol_str = | 880 base::DictionaryValue* alternate_protocol_dict = |
| 810 AlternateProtocolToString(port_alternate_protocol->protocol); | 881 new base::DictionaryValue; |
| 811 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); | 882 alternate_protocol_dict->SetInteger("port", alternate_protocol->port); |
| 812 port_alternate_protocol_dict->SetDouble( | 883 alternate_protocol_dict->SetString("host", server.host()); |
| 813 "probability", port_alternate_protocol->probability); | 884 alternate_protocol_dict->SetString( |
| 814 server_pref_dict->SetWithoutPathExpansion( | 885 "protocol_str", |
| 815 "alternate_protocol", port_alternate_protocol_dict); | 886 AlternateProtocolToString(alternate_protocol->protocol)); |
| 887 alternate_protocol_dict->SetDouble("probability", | |
| 888 alternate_protocol->probability); | |
| 889 alternate_protocols_list->Append(alternate_protocol_dict); | |
| 890 } | |
| 891 server_pref_dict->SetWithoutPathExpansion("alternative_services", | |
| 892 alternate_protocols_list); | |
| 816 } | 893 } |
| 817 | 894 |
| 818 // Save supports_quic. | 895 // Save supports_quic. |
| 819 if (server_pref.supports_quic) { | 896 if (server_pref.supports_quic) { |
| 820 base::DictionaryValue* supports_quic_dict = new base::DictionaryValue; | 897 base::DictionaryValue* supports_quic_dict = new base::DictionaryValue; |
| 821 const SupportsQuic* supports_quic = server_pref.supports_quic; | 898 const SupportsQuic* supports_quic = server_pref.supports_quic; |
| 822 supports_quic_dict->SetBoolean("used_quic", supports_quic->used_quic); | 899 supports_quic_dict->SetBoolean("used_quic", supports_quic->used_quic); |
| 823 supports_quic_dict->SetString("address", supports_quic->address); | 900 supports_quic_dict->SetString("address", supports_quic->address); |
| 824 server_pref_dict->SetWithoutPathExpansion( | 901 server_pref_dict->SetWithoutPathExpansion( |
| 825 "supports_quic", supports_quic_dict); | 902 "supports_quic", supports_quic_dict); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 completion.Run(); | 935 completion.Run(); |
| 859 } | 936 } |
| 860 | 937 |
| 861 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 938 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 862 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 939 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 863 if (!setting_prefs_) | 940 if (!setting_prefs_) |
| 864 ScheduleUpdateCacheOnPrefThread(); | 941 ScheduleUpdateCacheOnPrefThread(); |
| 865 } | 942 } |
| 866 | 943 |
| 867 } // namespace net | 944 } // namespace net |
| OLD | NEW |