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_macros.h" | 8 #include "base/metrics/histogram_macros.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 17 matching lines...) Expand all Loading... | |
28 // Time to wait before starting an update the preferences from the | 28 // Time to wait before starting an update the preferences from the |
29 // http_server_properties_impl_ cache. Scheduling another update during this | 29 // http_server_properties_impl_ cache. Scheduling another update during this |
30 // period will reset the timer. | 30 // period will reset the timer. |
31 const int64_t kUpdatePrefsDelayMs = 60000; | 31 const int64_t kUpdatePrefsDelayMs = 60000; |
32 | 32 |
33 // "version" 0 indicates, http_server_properties doesn't have "version" | 33 // "version" 0 indicates, http_server_properties doesn't have "version" |
34 // property. | 34 // property. |
35 const int kMissingVersion = 0; | 35 const int kMissingVersion = 0; |
36 | 36 |
37 // The version number of persisted http_server_properties. | 37 // The version number of persisted http_server_properties. |
38 const int kVersionNumber = 3; | 38 const int kVersionNumber = 4; |
39 | 39 |
40 // Persist 200 MRU AlternateProtocolHostPortPairs. | 40 // Persist 200 MRU AlternateProtocolHostPortPairs. |
41 const int kMaxAlternateProtocolHostsToPersist = 200; | 41 const int kMaxAlternateProtocolHostsToPersist = 200; |
42 | 42 |
43 // Persist 200 MRU SpdySettingsHostPortPairs. | 43 // Persist 200 MRU SpdySettingsHostPortPairs. |
44 const int kMaxSpdySettingsHostsToPersist = 200; | 44 const int kMaxSpdySettingsHostsToPersist = 200; |
45 | 45 |
46 // Persist 300 MRU SupportsSpdyServerHostPortPairs. | 46 // Persist 300 MRU SupportsSpdyServerHostPortPairs. |
47 const int kMaxSupportsSpdyServerHostsToPersist = 300; | 47 const int kMaxSupportsSpdyServerHostsToPersist = 300; |
48 | 48 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 const base::DictionaryValue& http_server_properties_dict = | 438 const base::DictionaryValue& http_server_properties_dict = |
439 *pref_service_->GetDictionary(path_); | 439 *pref_service_->GetDictionary(path_); |
440 | 440 |
441 int version = kMissingVersion; | 441 int version = kMissingVersion; |
442 if (!http_server_properties_dict.GetIntegerWithoutPathExpansion(kVersionKey, | 442 if (!http_server_properties_dict.GetIntegerWithoutPathExpansion(kVersionKey, |
443 &version)) { | 443 &version)) { |
444 DVLOG(1) << "Missing version. Clearing all properties."; | 444 DVLOG(1) << "Missing version. Clearing all properties."; |
445 return; | 445 return; |
446 } | 446 } |
447 | 447 |
448 // The properties for a given server is in | |
449 // http_server_properties_dict["servers"][server]. | |
450 // Server data was stored in the following format in alphabetical order. | |
451 // | |
452 // "http_server_properties": { | |
453 // "servers": { | |
454 // "accounts.google.com:443": {...}, | |
455 // "accounts.youtube.com:443": {...}, | |
456 // "android.clients.google.com:443": {...}, | |
457 // ... | |
458 // }, ... | |
459 // }, | |
460 const base::DictionaryValue* servers_dict = NULL; | 448 const base::DictionaryValue* servers_dict = NULL; |
461 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( | 449 const base::ListValue* servers_list = NULL; |
Bence
2016/01/05 18:45:47
Optional: change |NULL| to |nullptr| in both lines
ramant (doing other things)
2016/01/05 18:52:58
Done.
| |
462 kServersKey, &servers_dict)) { | 450 if (version < 4) { |
463 DVLOG(1) << "Malformed http_server_properties for servers."; | 451 // The properties for a given server is in |
464 return; | 452 // http_server_properties_dict["servers"][server]. |
453 // Before Version 4, server data was stored in the following format in | |
454 // alphabetical order. | |
455 // | |
456 // "http_server_properties": { | |
457 // "servers": { | |
458 // "0-edge-chat.facebook.com:443" : {...}, | |
459 // "0.client-channel.google.com:443" : {...}, | |
460 // "yt3.ggpht.com:443" : {...}, | |
461 // ... | |
462 // }, ... | |
463 // }, | |
464 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( | |
465 kServersKey, &servers_dict)) { | |
466 DVLOG(1) << "Malformed http_server_properties for servers."; | |
467 return; | |
468 } | |
469 } else { | |
470 // From Version 4 onwards, data was stored in the following format. | |
471 // |servers| are saved in MRU order. | |
472 // | |
473 // "http_server_properties": { | |
474 // "servers": [ | |
475 // {"yt3.ggpht.com:443" : {...}}, | |
476 // {"0.client-channel.google.com:443" : {...}}, | |
477 // {"0-edge-chat.facebook.com:443" : {...}}, | |
478 // ... | |
479 // ], ... | |
480 // }, | |
481 if (!http_server_properties_dict.GetListWithoutPathExpansion( | |
482 kServersKey, &servers_list)) { | |
483 DVLOG(1) << "Malformed http_server_properties for servers list."; | |
484 return; | |
485 } | |
465 } | 486 } |
466 | 487 |
467 IPAddressNumber* addr = new IPAddressNumber; | 488 IPAddressNumber* addr = new IPAddressNumber; |
468 ReadSupportsQuic(http_server_properties_dict, addr); | 489 ReadSupportsQuic(http_server_properties_dict, addr); |
469 | 490 |
470 // String is host/port pair of spdy server. | 491 // String is host/port pair of spdy server. |
471 scoped_ptr<ServerList> spdy_servers(new ServerList); | 492 scoped_ptr<ServerList> spdy_servers(new ServerList); |
472 scoped_ptr<SpdySettingsMap> spdy_settings_map( | 493 scoped_ptr<SpdySettingsMap> spdy_settings_map( |
473 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); | 494 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist)); |
474 scoped_ptr<AlternativeServiceMap> alternative_service_map( | 495 scoped_ptr<AlternativeServiceMap> alternative_service_map( |
475 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); | 496 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist)); |
476 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( | 497 scoped_ptr<ServerNetworkStatsMap> server_network_stats_map( |
477 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); | 498 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist)); |
478 scoped_ptr<QuicServerInfoMap> quic_server_info_map( | 499 scoped_ptr<QuicServerInfoMap> quic_server_info_map( |
479 new QuicServerInfoMap(kMaxQuicServersToPersist)); | 500 new QuicServerInfoMap(kMaxQuicServersToPersist)); |
480 | 501 |
481 if (!AddServersData(*servers_dict, spdy_servers.get(), | 502 if (version < 4) { |
482 spdy_settings_map.get(), alternative_service_map.get(), | 503 if (!AddServersData(*servers_dict, spdy_servers.get(), |
483 server_network_stats_map.get())) { | 504 spdy_settings_map.get(), alternative_service_map.get(), |
484 detected_corrupted_prefs = true; | 505 server_network_stats_map.get())) { |
506 detected_corrupted_prefs = true; | |
507 } | |
508 } else { | |
509 for (base::ListValue::const_iterator it = servers_list->begin(); | |
510 it != servers_list->end(); ++it) { | |
511 if (!(*it)->GetAsDictionary(&servers_dict)) { | |
512 DVLOG(1) << "Malformed http_server_properties for servers dictionary."; | |
513 detected_corrupted_prefs = true; | |
514 continue; | |
515 } | |
516 if (!AddServersData( | |
517 *servers_dict, spdy_servers.get(), spdy_settings_map.get(), | |
518 alternative_service_map.get(), server_network_stats_map.get())) { | |
519 detected_corrupted_prefs = true; | |
520 } | |
521 } | |
485 } | 522 } |
486 | 523 |
487 if (!AddToQuicServerInfoMap(http_server_properties_dict, | 524 if (!AddToQuicServerInfoMap(http_server_properties_dict, |
488 quic_server_info_map.get())) { | 525 quic_server_info_map.get())) { |
489 detected_corrupted_prefs = true; | 526 detected_corrupted_prefs = true; |
490 } | 527 } |
491 | 528 |
492 network_task_runner_->PostTask( | 529 network_task_runner_->PostTask( |
493 FROM_HERE, | 530 FROM_HERE, |
494 base::Bind( | 531 base::Bind( |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 | 891 |
855 // This is required so we can set this as the callback for a timer. | 892 // This is required so we can set this as the callback for a timer. |
856 void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread() { | 893 void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread() { |
857 UpdatePrefsFromCacheOnNetworkThread(base::Closure()); | 894 UpdatePrefsFromCacheOnNetworkThread(base::Closure()); |
858 } | 895 } |
859 | 896 |
860 void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread( | 897 void HttpServerPropertiesManager::UpdatePrefsFromCacheOnNetworkThread( |
861 const base::Closure& completion) { | 898 const base::Closure& completion) { |
862 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 899 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
863 | 900 |
901 // It is in MRU order. | |
864 base::ListValue* spdy_server_list = new base::ListValue; | 902 base::ListValue* spdy_server_list = new base::ListValue; |
865 http_server_properties_impl_->GetSpdyServerList( | 903 http_server_properties_impl_->GetSpdyServerList( |
866 spdy_server_list, kMaxSupportsSpdyServerHostsToPersist); | 904 spdy_server_list, kMaxSupportsSpdyServerHostsToPersist); |
867 | 905 |
868 SpdySettingsMap* spdy_settings_map = | 906 SpdySettingsMap* spdy_settings_map = |
869 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist); | 907 new SpdySettingsMap(kMaxSpdySettingsHostsToPersist); |
870 const SpdySettingsMap& main_map = | 908 const SpdySettingsMap& main_map = |
871 http_server_properties_impl_->spdy_settings_map(); | 909 http_server_properties_impl_->spdy_settings_map(); |
872 int count = 0; | 910 int count = 0; |
873 for (SpdySettingsMap::const_iterator it = main_map.begin(); | 911 // Maintain MRU order. |
874 it != main_map.end() && count < kMaxSpdySettingsHostsToPersist; | 912 for (SpdySettingsMap::const_reverse_iterator it = main_map.rbegin(); |
913 it != main_map.rend() && count < kMaxSpdySettingsHostsToPersist; | |
875 ++it, ++count) { | 914 ++it, ++count) { |
876 spdy_settings_map->Put(it->first, it->second); | 915 spdy_settings_map->Put(it->first, it->second); |
877 } | 916 } |
878 | 917 |
879 AlternativeServiceMap* alternative_service_map = | 918 AlternativeServiceMap* alternative_service_map = |
880 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist); | 919 new AlternativeServiceMap(kMaxAlternateProtocolHostsToPersist); |
881 const AlternativeServiceMap& map = | 920 const AlternativeServiceMap& map = |
882 http_server_properties_impl_->alternative_service_map(); | 921 http_server_properties_impl_->alternative_service_map(); |
883 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers.Memory", | 922 UMA_HISTOGRAM_COUNTS("Net.CountOfAlternateProtocolServers.Memory", |
884 map.size()); | 923 map.size()); |
885 count = 0; | 924 count = 0; |
886 typedef std::map<std::string, bool> CanonicalHostPersistedMap; | 925 typedef std::map<std::string, bool> CanonicalHostPersistedMap; |
887 CanonicalHostPersistedMap persisted_map; | 926 CanonicalHostPersistedMap persisted_map; |
888 for (AlternativeServiceMap::const_iterator it = map.begin(); | 927 // Maintain MRU order. |
889 it != map.end() && count < kMaxAlternateProtocolHostsToPersist; ++it) { | 928 for (AlternativeServiceMap::const_reverse_iterator it = map.rbegin(); |
929 it != map.rend() && count < kMaxAlternateProtocolHostsToPersist; ++it) { | |
890 const HostPortPair& server = it->first; | 930 const HostPortPair& server = it->first; |
891 AlternativeServiceInfoVector notbroken_alternative_service_info_vector; | 931 AlternativeServiceInfoVector notbroken_alternative_service_info_vector; |
892 for (const AlternativeServiceInfo& alternative_service_info : it->second) { | 932 for (const AlternativeServiceInfo& alternative_service_info : it->second) { |
893 // Do not persist expired entries. | 933 // Do not persist expired entries. |
894 if (alternative_service_info.expiration < base::Time::Now()) { | 934 if (alternative_service_info.expiration < base::Time::Now()) { |
895 continue; | 935 continue; |
896 } | 936 } |
897 AlternativeService alternative_service( | 937 AlternativeService alternative_service( |
898 alternative_service_info.alternative_service); | 938 alternative_service_info.alternative_service); |
899 if (!IsAlternateProtocolValid(alternative_service.protocol)) { | 939 if (!IsAlternateProtocolValid(alternative_service.protocol)) { |
(...skipping 21 matching lines...) Expand all Loading... | |
921 alternative_service_map->Put(server, | 961 alternative_service_map->Put(server, |
922 notbroken_alternative_service_info_vector); | 962 notbroken_alternative_service_info_vector); |
923 ++count; | 963 ++count; |
924 } | 964 } |
925 | 965 |
926 ServerNetworkStatsMap* server_network_stats_map = | 966 ServerNetworkStatsMap* server_network_stats_map = |
927 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist); | 967 new ServerNetworkStatsMap(kMaxServerNetworkStatsHostsToPersist); |
928 const ServerNetworkStatsMap& network_stats_map = | 968 const ServerNetworkStatsMap& network_stats_map = |
929 http_server_properties_impl_->server_network_stats_map(); | 969 http_server_properties_impl_->server_network_stats_map(); |
930 count = 0; | 970 count = 0; |
931 for (ServerNetworkStatsMap::const_iterator it = network_stats_map.begin(); | 971 for (ServerNetworkStatsMap::const_reverse_iterator |
932 it != network_stats_map.end() && | 972 it = network_stats_map.rbegin(); |
973 it != network_stats_map.rend() && | |
933 count < kMaxServerNetworkStatsHostsToPersist; | 974 count < kMaxServerNetworkStatsHostsToPersist; |
934 ++it, ++count) { | 975 ++it, ++count) { |
935 server_network_stats_map->Put(it->first, it->second); | 976 server_network_stats_map->Put(it->first, it->second); |
936 } | 977 } |
937 | 978 |
938 QuicServerInfoMap* quic_server_info_map = NULL; | 979 QuicServerInfoMap* quic_server_info_map = NULL; |
939 const QuicServerInfoMap& main_quic_server_info_map = | 980 const QuicServerInfoMap& main_quic_server_info_map = |
940 http_server_properties_impl_->quic_server_info_map(); | 981 http_server_properties_impl_->quic_server_info_map(); |
941 if (main_quic_server_info_map.size() > 0) { | 982 if (main_quic_server_info_map.size() > 0) { |
942 quic_server_info_map = new QuicServerInfoMap(kMaxQuicServersToPersist); | 983 quic_server_info_map = new QuicServerInfoMap(kMaxQuicServersToPersist); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
980 alternative_service_info_vector(alternative_service_info_vector), | 1021 alternative_service_info_vector(alternative_service_info_vector), |
981 supports_quic(supports_quic), | 1022 supports_quic(supports_quic), |
982 server_network_stats(server_network_stats) {} | 1023 server_network_stats(server_network_stats) {} |
983 bool supports_spdy; | 1024 bool supports_spdy; |
984 const SettingsMap* settings_map; | 1025 const SettingsMap* settings_map; |
985 const AlternativeServiceInfoVector* alternative_service_info_vector; | 1026 const AlternativeServiceInfoVector* alternative_service_info_vector; |
986 const SupportsQuic* supports_quic; | 1027 const SupportsQuic* supports_quic; |
987 const ServerNetworkStats* server_network_stats; | 1028 const ServerNetworkStats* server_network_stats; |
988 }; | 1029 }; |
989 | 1030 |
1031 // All maps and lists are in MRU order. | |
990 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( | 1032 void HttpServerPropertiesManager::UpdatePrefsOnPrefThread( |
991 base::ListValue* spdy_server_list, | 1033 base::ListValue* spdy_server_list, |
992 SpdySettingsMap* spdy_settings_map, | 1034 SpdySettingsMap* spdy_settings_map, |
993 AlternativeServiceMap* alternative_service_map, | 1035 AlternativeServiceMap* alternative_service_map, |
994 IPAddressNumber* last_quic_address, | 1036 IPAddressNumber* last_quic_address, |
995 ServerNetworkStatsMap* server_network_stats_map, | 1037 ServerNetworkStatsMap* server_network_stats_map, |
996 QuicServerInfoMap* quic_server_info_map, | 1038 QuicServerInfoMap* quic_server_info_map, |
997 const base::Closure& completion) { | 1039 const base::Closure& completion) { |
998 typedef std::map<HostPortPair, ServerPref> ServerPrefMap; | 1040 typedef base::MRUCache<HostPortPair, ServerPref> ServerPrefMap; |
999 ServerPrefMap server_pref_map; | 1041 ServerPrefMap server_pref_map(ServerPrefMap::NO_AUTO_EVICT); |
1000 | 1042 |
1001 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1043 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
1002 | 1044 |
1003 // Add servers that support spdy to server_pref_map. | 1045 // Add servers that support spdy to server_pref_map in the MRU order. |
1004 std::string s; | 1046 for (size_t index = spdy_server_list->GetSize(); index > 0; --index) { |
1005 for (base::ListValue::const_iterator list_it = spdy_server_list->begin(); | 1047 std::string s; |
1006 list_it != spdy_server_list->end(); | 1048 if (spdy_server_list->GetString(index - 1, &s)) { |
1007 ++list_it) { | |
1008 if ((*list_it)->GetAsString(&s)) { | |
1009 HostPortPair server = HostPortPair::FromString(s); | 1049 HostPortPair server = HostPortPair::FromString(s); |
1010 server_pref_map[server].supports_spdy = true; | 1050 ServerPrefMap::iterator it = server_pref_map.Get(server); |
1051 if (it == server_pref_map.end()) { | |
1052 ServerPref server_pref; | |
1053 server_pref.supports_spdy = true; | |
1054 server_pref_map.Put(server, server_pref); | |
1055 } else { | |
1056 it->second.supports_spdy = true; | |
1057 } | |
1011 } | 1058 } |
1012 } | 1059 } |
1013 | 1060 |
1014 // Add servers that have SpdySettings to server_pref_map. | 1061 // Add servers that have SpdySettings to server_pref_map in the MRU order. |
1015 for (SpdySettingsMap::iterator map_it = spdy_settings_map->begin(); | 1062 for (SpdySettingsMap::reverse_iterator map_it = spdy_settings_map->rbegin(); |
1016 map_it != spdy_settings_map->end(); ++map_it) { | 1063 map_it != spdy_settings_map->rend(); ++map_it) { |
1017 const HostPortPair& server = map_it->first; | 1064 const HostPortPair& server = map_it->first; |
1018 server_pref_map[server].settings_map = &map_it->second; | 1065 ServerPrefMap::iterator it = server_pref_map.Get(server); |
1066 if (it == server_pref_map.end()) { | |
1067 ServerPref server_pref; | |
1068 server_pref.settings_map = &map_it->second; | |
1069 server_pref_map.Put(server, server_pref); | |
1070 } else { | |
1071 it->second.settings_map = &map_it->second; | |
1072 } | |
1019 } | 1073 } |
1020 | 1074 |
1021 // Add alternative services to server_pref_map. | 1075 // Add alternative services to server_pref_map in the MRU order. |
1022 for (AlternativeServiceMap::const_iterator map_it = | 1076 for (AlternativeServiceMap::const_reverse_iterator map_it = |
1023 alternative_service_map->begin(); | 1077 alternative_service_map->rbegin(); |
1024 map_it != alternative_service_map->end(); ++map_it) { | 1078 map_it != alternative_service_map->rend(); ++map_it) { |
1025 server_pref_map[map_it->first].alternative_service_info_vector = | 1079 const HostPortPair& server = map_it->first; |
1026 &map_it->second; | 1080 ServerPrefMap::iterator it = server_pref_map.Get(server); |
1081 if (it == server_pref_map.end()) { | |
1082 ServerPref server_pref; | |
1083 server_pref.alternative_service_info_vector = &map_it->second; | |
1084 server_pref_map.Put(server, server_pref); | |
1085 } else { | |
1086 it->second.alternative_service_info_vector = &map_it->second; | |
1087 } | |
1027 } | 1088 } |
1028 | 1089 |
1029 // Add ServerNetworkStats servers to server_pref_map. | 1090 // Add ServerNetworkStats servers to server_pref_map in the MRU order. |
1030 for (ServerNetworkStatsMap::const_iterator map_it = | 1091 for (ServerNetworkStatsMap::const_reverse_iterator map_it = |
1031 server_network_stats_map->begin(); | 1092 server_network_stats_map->rbegin(); |
1032 map_it != server_network_stats_map->end(); ++map_it) { | 1093 map_it != server_network_stats_map->rend(); ++map_it) { |
1033 const HostPortPair& server = map_it->first; | 1094 const HostPortPair& server = map_it->first; |
1034 server_pref_map[server].server_network_stats = &map_it->second; | 1095 ServerPrefMap::iterator it = server_pref_map.Get(server); |
1096 if (it == server_pref_map.end()) { | |
1097 ServerPref server_pref; | |
1098 server_pref.server_network_stats = &map_it->second; | |
1099 server_pref_map.Put(server, server_pref); | |
1100 } else { | |
1101 it->second.server_network_stats = &map_it->second; | |
1102 } | |
1035 } | 1103 } |
1036 | 1104 |
1037 // Persist properties to the |path_|. | 1105 // Persist properties to the |path_| in the MRU order. |
1038 base::DictionaryValue http_server_properties_dict; | 1106 base::DictionaryValue http_server_properties_dict; |
1039 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 1107 base::ListValue* servers_list = new base::ListValue; |
1040 for (ServerPrefMap::const_iterator map_it = server_pref_map.begin(); | 1108 for (ServerPrefMap::const_reverse_iterator map_it = server_pref_map.rbegin(); |
1041 map_it != server_pref_map.end(); | 1109 map_it != server_pref_map.rend(); ++map_it) { |
1042 ++map_it) { | |
1043 const HostPortPair& server = map_it->first; | 1110 const HostPortPair& server = map_it->first; |
1044 const ServerPref& server_pref = map_it->second; | 1111 const ServerPref& server_pref = map_it->second; |
1045 | 1112 |
1113 base::DictionaryValue* servers_dict = new base::DictionaryValue; | |
1046 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 1114 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; |
1047 | 1115 |
1048 // Save supports_spdy. | 1116 // Save supports_spdy. |
1049 if (server_pref.supports_spdy) | 1117 if (server_pref.supports_spdy) |
1050 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy); | 1118 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy); |
1051 SaveSpdySettingsToServerPrefs(server_pref.settings_map, server_pref_dict); | 1119 SaveSpdySettingsToServerPrefs(server_pref.settings_map, server_pref_dict); |
1052 SaveAlternativeServiceToServerPrefs( | 1120 SaveAlternativeServiceToServerPrefs( |
1053 server_pref.alternative_service_info_vector, server_pref_dict); | 1121 server_pref.alternative_service_info_vector, server_pref_dict); |
1054 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats, | 1122 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats, |
1055 server_pref_dict); | 1123 server_pref_dict); |
1056 | 1124 |
1057 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); | 1125 servers_dict->SetWithoutPathExpansion(server.ToString(), server_pref_dict); |
1126 bool value = servers_list->AppendIfNotPresent(servers_dict); | |
1127 DCHECK(value); // Should never happen. | |
1058 } | 1128 } |
1059 | 1129 |
1060 http_server_properties_dict.SetWithoutPathExpansion(kServersKey, | 1130 http_server_properties_dict.SetWithoutPathExpansion(kServersKey, |
1061 servers_dict); | 1131 servers_list); |
1062 SetVersion(&http_server_properties_dict, kVersionNumber); | 1132 SetVersion(&http_server_properties_dict, kVersionNumber); |
1063 | 1133 |
1064 SaveSupportsQuicToPrefs(last_quic_address, &http_server_properties_dict); | 1134 SaveSupportsQuicToPrefs(last_quic_address, &http_server_properties_dict); |
1065 | 1135 |
1066 SaveQuicServerInfoMapToServerPrefs(quic_server_info_map, | 1136 SaveQuicServerInfoMapToServerPrefs(quic_server_info_map, |
1067 &http_server_properties_dict); | 1137 &http_server_properties_dict); |
1068 | 1138 |
1069 setting_prefs_ = true; | 1139 setting_prefs_ = true; |
1070 pref_service_->Set(path_, http_server_properties_dict); | 1140 pref_service_->Set(path_, http_server_properties_dict); |
1071 setting_prefs_ = false; | 1141 setting_prefs_ = false; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 quic_servers_dict); | 1250 quic_servers_dict); |
1181 } | 1251 } |
1182 | 1252 |
1183 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 1253 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
1184 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1254 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
1185 if (!setting_prefs_) | 1255 if (!setting_prefs_) |
1186 ScheduleUpdateCacheOnPrefThread(); | 1256 ScheduleUpdateCacheOnPrefThread(); |
1187 } | 1257 } |
1188 | 1258 |
1189 } // namespace net | 1259 } // namespace net |
OLD | NEW |