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

Side by Side Diff: net/http/http_server_properties_manager.cc

Issue 665083009: ABANDONED Handle multiple AlternateProtocols for each HostPortPair. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re: 18. Created 5 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 unified diff | Download patch
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const int kMaxServerNetworkStatsHostsToPersist = 200; 51 const int kMaxServerNetworkStatsHostsToPersist = 200;
52 52
53 const char kVersionKey[] = "version"; 53 const char kVersionKey[] = "version";
54 const char kServersKey[] = "servers"; 54 const char kServersKey[] = "servers";
55 const char kSupportsSpdyKey[] = "supports_spdy"; 55 const char kSupportsSpdyKey[] = "supports_spdy";
56 const char kSettingsKey[] = "settings"; 56 const char kSettingsKey[] = "settings";
57 const char kSupportsQuicKey[] = "supports_quic"; 57 const char kSupportsQuicKey[] = "supports_quic";
58 const char kUsedQuicKey[] = "used_quic"; 58 const char kUsedQuicKey[] = "used_quic";
59 const char kAddressKey[] = "address"; 59 const char kAddressKey[] = "address";
60 const char kAlternateProtocolKey[] = "alternate_protocol"; 60 const char kAlternateProtocolKey[] = "alternate_protocol";
61 const char kAlternativeServicesKey[] = "alternative_services";
61 const char kPortKey[] = "port"; 62 const char kPortKey[] = "port";
63 const char kHostKey[] = "host";
62 const char kProtocolKey[] = "protocol_str"; 64 const char kProtocolKey[] = "protocol_str";
63 const char kProbabilityKey[] = "probability"; 65 const char kProbabilityKey[] = "probability";
64 const char kNetworkStatsKey[] = "network_stats"; 66 const char kNetworkStatsKey[] = "network_stats";
65 const char kSrttKey[] = "srtt"; 67 const char kSrttKey[] = "srtt";
66 68
67 } // namespace 69 } // namespace
68 70
69 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
70 // HttpServerPropertiesManager 72 // HttpServerPropertiesManager
71 73
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 http_server_properties_impl_->SetHTTP11Required(server); 175 http_server_properties_impl_->SetHTTP11Required(server);
174 ScheduleUpdatePrefsOnNetworkThread(); 176 ScheduleUpdatePrefsOnNetworkThread();
175 } 177 }
176 178
177 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server, 179 void HttpServerPropertiesManager::MaybeForceHTTP11(const HostPortPair& server,
178 SSLConfig* ssl_config) { 180 SSLConfig* ssl_config) {
179 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 181 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
180 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config); 182 http_server_properties_impl_->MaybeForceHTTP11(server, ssl_config);
181 } 183 }
182 184
183 AlternateProtocolInfo HttpServerPropertiesManager::GetAlternateProtocol( 185 AlternateProtocols HttpServerPropertiesManager::GetAlternateProtocols(
184 const HostPortPair& server) { 186 const HostPortPair& server) {
185 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 187 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
186 return http_server_properties_impl_->GetAlternateProtocol(server); 188 return http_server_properties_impl_->GetAlternateProtocols(server);
187 } 189 }
188 190
189 void HttpServerPropertiesManager::SetAlternateProtocol( 191 void HttpServerPropertiesManager::AddAlternateProtocol(
190 const HostPortPair& server, 192 const HostPortPair& server,
191 uint16 alternate_port, 193 uint16 alternate_port,
192 AlternateProtocol alternate_protocol, 194 AlternateProtocol alternate_protocol,
193 double alternate_probability) { 195 double alternate_probability) {
194 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 196 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
195 http_server_properties_impl_->SetAlternateProtocol( 197 http_server_properties_impl_->AddAlternateProtocol(
196 server, alternate_port, alternate_protocol, alternate_probability); 198 server, alternate_port, alternate_protocol, alternate_probability);
197 ScheduleUpdatePrefsOnNetworkThread(); 199 ScheduleUpdatePrefsOnNetworkThread();
198 } 200 }
199 201
200 void HttpServerPropertiesManager::SetBrokenAlternateProtocol( 202 void HttpServerPropertiesManager::SetBrokenAlternateProtocol(
201 const HostPortPair& server) { 203 const HostPortPair& server,
204 const AlternateProtocolInfo& broken_alternate_protocol) {
202 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 205 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
203 http_server_properties_impl_->SetBrokenAlternateProtocol(server); 206 http_server_properties_impl_->SetBrokenAlternateProtocol(
207 server, broken_alternate_protocol);
204 ScheduleUpdatePrefsOnNetworkThread(); 208 ScheduleUpdatePrefsOnNetworkThread();
205 } 209 }
206 210
207 bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken( 211 bool HttpServerPropertiesManager::WasAlternateProtocolRecentlyBroken(
208 const HostPortPair& server) { 212 const HostPortPair& server,
213 const AlternateProtocolInfo& alternate_protocol) const {
209 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 214 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
210 return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken( 215 return http_server_properties_impl_->WasAlternateProtocolRecentlyBroken(
211 server); 216 server, alternate_protocol);
212 } 217 }
213 218
214 void HttpServerPropertiesManager::ConfirmAlternateProtocol( 219 void HttpServerPropertiesManager::ConfirmAlternateProtocol(
215 const HostPortPair& server) { 220 const HostPortPair& server,
221 const AlternateProtocolInfo& alternate_protocol) {
216 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 222 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
217 http_server_properties_impl_->ConfirmAlternateProtocol(server); 223 http_server_properties_impl_->ConfirmAlternateProtocol(server,
224 alternate_protocol);
218 ScheduleUpdatePrefsOnNetworkThread(); 225 ScheduleUpdatePrefsOnNetworkThread();
219 } 226 }
220 227
221 void HttpServerPropertiesManager::ClearAlternateProtocol( 228 void HttpServerPropertiesManager::ClearAlternateProtocols(
222 const HostPortPair& server) { 229 const HostPortPair& server) {
223 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 230 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
224 http_server_properties_impl_->ClearAlternateProtocol(server); 231 http_server_properties_impl_->ClearAlternateProtocols(server);
225 ScheduleUpdatePrefsOnNetworkThread(); 232 ScheduleUpdatePrefsOnNetworkThread();
226 } 233 }
227 234
235 void HttpServerPropertiesManager::ClearNonBrokenAlternateProtocols(
236 const HostPortPair& server) {
237 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
238 http_server_properties_impl_->ClearNonBrokenAlternateProtocols(server);
239 ScheduleUpdatePrefsOnNetworkThread();
240 }
241
242 void HttpServerPropertiesManager::RemoveAlternateProtocol(
243 const HostPortPair& server,
244 const AlternateProtocolInfo& alternate_protocol) {
245 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
246 http_server_properties_impl_->RemoveAlternateProtocol(server,
247 alternate_protocol);
248 ScheduleUpdatePrefsOnNetworkThread();
249 }
250
228 const AlternateProtocolMap& 251 const AlternateProtocolMap&
229 HttpServerPropertiesManager::alternate_protocol_map() const { 252 HttpServerPropertiesManager::alternate_protocol_map() const {
230 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 253 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
231 return http_server_properties_impl_->alternate_protocol_map(); 254 return http_server_properties_impl_->alternate_protocol_map();
232 } 255 }
233 256
234 void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold( 257 void HttpServerPropertiesManager::SetAlternateProtocolProbabilityThreshold(
235 double threshold) { 258 double threshold) {
236 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 259 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
237 http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold( 260 http_server_properties_impl_->SetAlternateProtocolProbabilityThreshold(
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 507 }
485 alternate_protocol.protocol = protocol; 508 alternate_protocol.protocol = protocol;
486 509
487 return alternate_protocol; 510 return alternate_protocol;
488 } 511 }
489 512
490 bool HttpServerPropertiesManager::AddToAlternateProtocolMap( 513 bool HttpServerPropertiesManager::AddToAlternateProtocolMap(
491 const HostPortPair& server, 514 const HostPortPair& server,
492 const base::DictionaryValue& server_pref_dict, 515 const base::DictionaryValue& server_pref_dict,
493 AlternateProtocolMap* alternate_protocol_map) { 516 AlternateProtocolMap* alternate_protocol_map) {
494 // Get alternate_protocol server.
495 DCHECK(alternate_protocol_map->Peek(server) == alternate_protocol_map->end()); 517 DCHECK(alternate_protocol_map->Peek(server) == alternate_protocol_map->end());
496 const base::DictionaryValue* alternate_protocol_dict = NULL; 518 // Get alternative_services...
519 const base::ListValue* alternate_protocol_list = NULL;
520 if (server_pref_dict.GetListWithoutPathExpansion(kAlternativeServicesKey,
521 &alternate_protocol_list) &&
522 !alternate_protocol_list->empty()) {
523 AlternateProtocols alternate_protocols;
524 for (base::Value* const alternate_protocol_list_item :
525 *alternate_protocol_list) {
526 base::DictionaryValue* alternate_protocol_dict;
527 if (!alternate_protocol_list_item->GetAsDictionary(
528 &alternate_protocol_dict))
529 return false;
530 AlternateProtocolInfo alternate_protocol = ParseAlternateProtocolDict(
531 *alternate_protocol_dict, server.ToString());
532 if (alternate_protocol.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
533 return false;
534 }
535 alternate_protocols.push_back(alternate_protocol);
536 }
537 alternate_protocol_map->Put(server, alternate_protocols);
538 return true;
539 }
540
541 // ...or alternate_protocol.
542 // TODO(bnc): Remove this in M45. (Saving to kAlternativeServicesKey is
543 // targeted to M43, and we do not need preference migration for long.)
544 const base::DictionaryValue* alternate_protocol_dict;
497 if (!server_pref_dict.GetDictionaryWithoutPathExpansion( 545 if (!server_pref_dict.GetDictionaryWithoutPathExpansion(
498 kAlternateProtocolKey, &alternate_protocol_dict)) { 546 kAlternateProtocolKey, &alternate_protocol_dict)) {
499 return true; 547 return true;
500 } 548 }
501 AlternateProtocolInfo alternate_protocol = 549 AlternateProtocolInfo alternate_protocol =
502 ParseAlternateProtocolDict(*alternate_protocol_dict, server.ToString()); 550 ParseAlternateProtocolDict(*alternate_protocol_dict, server.ToString());
503 if (alternate_protocol.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) 551 if (alternate_protocol.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
504 return false; 552 return false;
505 alternate_protocol_map->Put(server, alternate_protocol); 553 }
554 alternate_protocol_map->Put(
555 server, AlternateProtocols(/*size=*/1, alternate_protocol));
506 return true; 556 return true;
507 } 557 }
508 558
509 bool HttpServerPropertiesManager::ReadSupportsQuic( 559 bool HttpServerPropertiesManager::ReadSupportsQuic(
510 const base::DictionaryValue& http_server_properties_dict, 560 const base::DictionaryValue& http_server_properties_dict,
511 IPAddressNumber* last_quic_address) { 561 IPAddressNumber* last_quic_address) {
512 const base::DictionaryValue* supports_quic_dict = NULL; 562 const base::DictionaryValue* supports_quic_dict = NULL;
513 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( 563 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion(
514 kSupportsQuicKey, &supports_quic_dict)) { 564 kSupportsQuicKey, &supports_quic_dict)) {
515 return true; 565 return true;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 pref_task_runner_->PostTask( 727 pref_task_runner_->PostTask(
678 FROM_HERE, 728 FROM_HERE,
679 base::Bind( 729 base::Bind(
680 &HttpServerPropertiesManager::UpdatePrefsOnPrefThread, pref_weak_ptr_, 730 &HttpServerPropertiesManager::UpdatePrefsOnPrefThread, pref_weak_ptr_,
681 base::Owned(spdy_server_list), base::Owned(spdy_settings_map), 731 base::Owned(spdy_server_list), base::Owned(spdy_settings_map),
682 base::Owned(alternate_protocol_map), base::Owned(last_quic_addr), 732 base::Owned(alternate_protocol_map), base::Owned(last_quic_addr),
683 base::Owned(server_network_stats_map), completion)); 733 base::Owned(server_network_stats_map), completion));
684 } 734 }
685 735
686 // A local or temporary data structure to hold |supports_spdy|, SpdySettings, 736 // A local or temporary data structure to hold |supports_spdy|, SpdySettings,
687 // AlternateProtocolInfo and SupportsQuic preferences for a server. This is used 737 // AlternateProtocols and SupportsQuic preferences for a server. This is used
688 // only in UpdatePrefsOnPrefThread. 738 // only in UpdatePrefsOnPrefThread.
689 struct ServerPref { 739 struct ServerPref {
690 ServerPref() 740 ServerPref()
691 : supports_spdy(false), 741 : supports_spdy(false),
692 settings_map(NULL), 742 settings_map(NULL),
693 alternate_protocol(NULL), 743 alternate_protocols(NULL),
694 supports_quic(NULL), 744 supports_quic(NULL),
695 server_network_stats(NULL) {} 745 server_network_stats(NULL) {}
696 ServerPref(bool supports_spdy, 746 ServerPref(bool supports_spdy,
697 const SettingsMap* settings_map, 747 const SettingsMap* settings_map,
698 const AlternateProtocolInfo* alternate_protocol, 748 const AlternateProtocols* alternate_protocols,
699 const SupportsQuic* supports_quic, 749 const SupportsQuic* supports_quic,
700 const ServerNetworkStats* server_network_stats) 750 const ServerNetworkStats* server_network_stats)
701 : supports_spdy(supports_spdy), 751 : supports_spdy(supports_spdy),
702 settings_map(settings_map), 752 settings_map(settings_map),
703 alternate_protocol(alternate_protocol), 753 alternate_protocols(alternate_protocols),
704 supports_quic(supports_quic), 754 supports_quic(supports_quic),
705 server_network_stats(server_network_stats) {} 755 server_network_stats(server_network_stats) {}
706 bool supports_spdy; 756 bool supports_spdy;
707 const SettingsMap* settings_map; 757 const SettingsMap* settings_map;
708 const AlternateProtocolInfo* alternate_protocol; 758 const AlternateProtocols* alternate_protocols;
709 const SupportsQuic* supports_quic; 759 const SupportsQuic* supports_quic;
710 const ServerNetworkStats* server_network_stats; 760 const ServerNetworkStats* server_network_stats;
711 }; 761 };
712 762
713 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( 763 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread(
714 base::ListValue* spdy_server_list, 764 base::ListValue* spdy_server_list,
715 SpdySettingsMap* spdy_settings_map, 765 SpdySettingsMap* spdy_settings_map,
716 AlternateProtocolMap* alternate_protocol_map, 766 AlternateProtocolMap* alternate_protocol_map,
717 IPAddressNumber* last_quic_address, 767 IPAddressNumber* last_quic_address,
718 ServerNetworkStatsMap* server_network_stats_map, 768 ServerNetworkStatsMap* server_network_stats_map,
(...skipping 19 matching lines...) Expand all
738 map_it != spdy_settings_map->end(); ++map_it) { 788 map_it != spdy_settings_map->end(); ++map_it) {
739 const HostPortPair& server = map_it->first; 789 const HostPortPair& server = map_it->first;
740 server_pref_map[server].settings_map = &map_it->second; 790 server_pref_map[server].settings_map = &map_it->second;
741 } 791 }
742 792
743 // Add AlternateProtocol servers to server_pref_map. 793 // Add AlternateProtocol servers to server_pref_map.
744 for (AlternateProtocolMap::const_iterator map_it = 794 for (AlternateProtocolMap::const_iterator map_it =
745 alternate_protocol_map->begin(); 795 alternate_protocol_map->begin();
746 map_it != alternate_protocol_map->end(); ++map_it) { 796 map_it != alternate_protocol_map->end(); ++map_it) {
747 const HostPortPair& server = map_it->first; 797 const HostPortPair& server = map_it->first;
748 const AlternateProtocolInfo& port_alternate_protocol = map_it->second; 798 ServerPrefMap::iterator it = server_pref_map.find(server);
749 if (!IsAlternateProtocolValid(port_alternate_protocol.protocol)) { 799 if (it == server_pref_map.end()) {
750 continue; 800 ServerPref server_pref(false, NULL, &map_it->second, NULL, NULL);
801 server_pref_map[server] = server_pref;
802 } else {
803 it->second.alternate_protocols = &map_it->second;
751 } 804 }
752 server_pref_map[server].alternate_protocol = &map_it->second;
753 } 805 }
754 806
755 // Add ServerNetworkStats servers to server_pref_map. 807 // Add ServerNetworkStats servers to server_pref_map.
756 for (ServerNetworkStatsMap::const_iterator map_it = 808 for (ServerNetworkStatsMap::const_iterator map_it =
757 server_network_stats_map->begin(); 809 server_network_stats_map->begin();
758 map_it != server_network_stats_map->end(); ++map_it) { 810 map_it != server_network_stats_map->end(); ++map_it) {
759 const HostPortPair& server = map_it->first; 811 const HostPortPair& server = map_it->first;
760 server_pref_map[server].server_network_stats = &map_it->second; 812 server_pref_map[server].server_network_stats = &map_it->second;
761 } 813 }
762 814
763 // Persist properties to the |path_|. 815 // Persist properties to the |path_|.
764 base::DictionaryValue http_server_properties_dict; 816 base::DictionaryValue http_server_properties_dict;
765 base::DictionaryValue* servers_dict = new base::DictionaryValue; 817 base::DictionaryValue* servers_dict = new base::DictionaryValue;
766 for (ServerPrefMap::const_iterator map_it = server_pref_map.begin(); 818 for (ServerPrefMap::const_iterator map_it = server_pref_map.begin();
767 map_it != server_pref_map.end(); 819 map_it != server_pref_map.end();
768 ++map_it) { 820 ++map_it) {
769 const HostPortPair& server = map_it->first; 821 const HostPortPair& server = map_it->first;
770 const ServerPref& server_pref = map_it->second; 822 const ServerPref& server_pref = map_it->second;
771 823
772 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; 824 base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
773 825
774 // Save supports_spdy. 826 // Save supports_spdy.
775 if (server_pref.supports_spdy) 827 if (server_pref.supports_spdy)
776 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy); 828 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy);
777 SaveSpdySettingsToServerPrefs(server_pref.settings_map, server_pref_dict); 829 SaveSpdySettingsToServerPrefs(server_pref.settings_map, server_pref_dict);
778 SaveAlternateProtocolToServerPrefs(server_pref.alternate_protocol, 830 SaveAlternateProtocolToServerPrefs(server_pref.alternate_protocols,
779 server_pref_dict); 831 server_pref_dict, server);
780 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats, 832 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats,
781 server_pref_dict); 833 server_pref_dict);
782 834
783 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); 835 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict);
784 } 836 }
785 837
786 http_server_properties_dict.SetWithoutPathExpansion(kServersKey, 838 http_server_properties_dict.SetWithoutPathExpansion(kServersKey,
787 servers_dict); 839 servers_dict);
788 SetVersion(&http_server_properties_dict, kVersionNumber); 840 SetVersion(&http_server_properties_dict, kVersionNumber);
789 841
(...skipping 22 matching lines...) Expand all
812 it != settings_map->end(); ++it) { 864 it != settings_map->end(); ++it) {
813 SpdySettingsIds id = it->first; 865 SpdySettingsIds id = it->first;
814 uint32 value = it->second.second; 866 uint32 value = it->second.second;
815 std::string key = base::StringPrintf("%u", id); 867 std::string key = base::StringPrintf("%u", id);
816 spdy_settings_dict->SetInteger(key, value); 868 spdy_settings_dict->SetInteger(key, value);
817 } 869 }
818 server_pref_dict->SetWithoutPathExpansion(kSettingsKey, spdy_settings_dict); 870 server_pref_dict->SetWithoutPathExpansion(kSettingsKey, spdy_settings_dict);
819 } 871 }
820 872
821 void HttpServerPropertiesManager::SaveAlternateProtocolToServerPrefs( 873 void HttpServerPropertiesManager::SaveAlternateProtocolToServerPrefs(
822 const AlternateProtocolInfo* port_alternate_protocol, 874 const AlternateProtocols* alternate_protocols,
823 base::DictionaryValue* server_pref_dict) { 875 base::DictionaryValue* server_pref_dict,
824 if (!port_alternate_protocol || port_alternate_protocol->is_broken) 876 const HostPortPair& server) {
877 if (!alternate_protocols || alternate_protocols->size() == 0)
825 return; 878 return;
826 879 base::ListValue* alternate_protocols_list = new base::ListValue;
827 base::DictionaryValue* port_alternate_protocol_dict = 880 for (const AlternateProtocolInfo& alternate_protocol : *alternate_protocols) {
828 new base::DictionaryValue; 881 if (alternate_protocol.is_broken)
829 port_alternate_protocol_dict->SetInteger(kPortKey, 882 continue;
830 port_alternate_protocol->port); 883 DCHECK(IsAlternateProtocolValid(alternate_protocol.protocol));
831 const char* protocol_str = 884 base::DictionaryValue* alternate_protocol_dict = new base::DictionaryValue;
832 AlternateProtocolToString(port_alternate_protocol->protocol); 885 alternate_protocol_dict->SetInteger(kPortKey, alternate_protocol.port);
833 port_alternate_protocol_dict->SetString(kProtocolKey, protocol_str); 886 alternate_protocol_dict->SetString(kHostKey, server.host());
834 port_alternate_protocol_dict->SetDouble(kProbabilityKey, 887 alternate_protocol_dict->SetString(
835 port_alternate_protocol->probability); 888 kProtocolKey, AlternateProtocolToString(alternate_protocol.protocol));
836 server_pref_dict->SetWithoutPathExpansion(kAlternateProtocolKey, 889 alternate_protocol_dict->SetDouble(kProbabilityKey,
837 port_alternate_protocol_dict); 890 alternate_protocol.probability);
891 alternate_protocols_list->Append(alternate_protocol_dict);
892 }
893 if (alternate_protocols_list->GetSize() == 0)
894 return;
895 server_pref_dict->SetWithoutPathExpansion(kAlternativeServicesKey,
896 alternate_protocols_list);
838 } 897 }
839 898
840 void HttpServerPropertiesManager::SaveSupportsQuicToPrefs( 899 void HttpServerPropertiesManager::SaveSupportsQuicToPrefs(
841 const IPAddressNumber* last_quic_address, 900 const IPAddressNumber* last_quic_address,
842 base::DictionaryValue* http_server_properties_dict) { 901 base::DictionaryValue* http_server_properties_dict) {
843 if (!last_quic_address || last_quic_address->empty()) 902 if (!last_quic_address || last_quic_address->empty())
844 return; 903 return;
845 904
846 base::DictionaryValue* supports_quic_dict = new base::DictionaryValue; 905 base::DictionaryValue* supports_quic_dict = new base::DictionaryValue;
847 supports_quic_dict->SetBoolean(kUsedQuicKey, true); 906 supports_quic_dict->SetBoolean(kUsedQuicKey, true);
(...skipping 19 matching lines...) Expand all
867 server_network_stats_dict); 926 server_network_stats_dict);
868 } 927 }
869 928
870 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 929 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
871 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 930 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
872 if (!setting_prefs_) 931 if (!setting_prefs_)
873 ScheduleUpdateCacheOnPrefThread(); 932 ScheduleUpdateCacheOnPrefThread();
874 } 933 }
875 934
876 } // namespace net 935 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698