| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "net/base/ip_address.h" | 18 #include "net/base/ip_address.h" |
| 18 #include "net/base/port_util.h" | 19 #include "net/base/port_util.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 } | 1104 } |
| 1104 | 1105 |
| 1105 // Persist properties to the prefs in the MRU order. | 1106 // Persist properties to the prefs in the MRU order. |
| 1106 base::DictionaryValue http_server_properties_dict; | 1107 base::DictionaryValue http_server_properties_dict; |
| 1107 base::ListValue* servers_list = new base::ListValue; | 1108 base::ListValue* servers_list = new base::ListValue; |
| 1108 for (ServerPrefMap::const_reverse_iterator map_it = server_pref_map.rbegin(); | 1109 for (ServerPrefMap::const_reverse_iterator map_it = server_pref_map.rbegin(); |
| 1109 map_it != server_pref_map.rend(); ++map_it) { | 1110 map_it != server_pref_map.rend(); ++map_it) { |
| 1110 const url::SchemeHostPort server = map_it->first; | 1111 const url::SchemeHostPort server = map_it->first; |
| 1111 const ServerPref& server_pref = map_it->second; | 1112 const ServerPref& server_pref = map_it->second; |
| 1112 | 1113 |
| 1113 base::DictionaryValue* servers_dict = new base::DictionaryValue; | 1114 auto servers_dict = base::MakeUnique<base::DictionaryValue>(); |
| 1114 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; | 1115 auto server_pref_dict = base::MakeUnique<base::DictionaryValue>(); |
| 1115 | 1116 |
| 1116 // Save supports_spdy. | 1117 // Save supports_spdy. |
| 1117 if (server_pref.supports_spdy) | 1118 if (server_pref.supports_spdy) |
| 1118 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy); | 1119 server_pref_dict->SetBoolean(kSupportsSpdyKey, server_pref.supports_spdy); |
| 1119 SaveSpdySettingsToServerPrefs(server_pref.settings_map, server_pref_dict); | 1120 SaveSpdySettingsToServerPrefs(server_pref.settings_map, |
| 1121 server_pref_dict.get()); |
| 1120 SaveAlternativeServiceToServerPrefs( | 1122 SaveAlternativeServiceToServerPrefs( |
| 1121 server_pref.alternative_service_info_vector, server_pref_dict); | 1123 server_pref.alternative_service_info_vector, server_pref_dict.get()); |
| 1122 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats, | 1124 SaveNetworkStatsToServerPrefs(server_pref.server_network_stats, |
| 1123 server_pref_dict); | 1125 server_pref_dict.get()); |
| 1124 | 1126 |
| 1125 servers_dict->SetWithoutPathExpansion(server.Serialize(), server_pref_dict); | 1127 servers_dict->SetWithoutPathExpansion(server.Serialize(), |
| 1126 bool value = servers_list->AppendIfNotPresent(servers_dict); | 1128 std::move(server_pref_dict)); |
| 1129 bool value = servers_list->AppendIfNotPresent(std::move(servers_dict)); |
| 1127 DCHECK(value); // Should never happen. | 1130 DCHECK(value); // Should never happen. |
| 1128 } | 1131 } |
| 1129 | 1132 |
| 1130 http_server_properties_dict.SetWithoutPathExpansion(kServersKey, | 1133 http_server_properties_dict.SetWithoutPathExpansion(kServersKey, |
| 1131 servers_list); | 1134 servers_list); |
| 1132 SetVersion(&http_server_properties_dict, kVersionNumber); | 1135 SetVersion(&http_server_properties_dict, kVersionNumber); |
| 1133 | 1136 |
| 1134 SaveSupportsQuicToPrefs(last_quic_address, &http_server_properties_dict); | 1137 SaveSupportsQuicToPrefs(last_quic_address, &http_server_properties_dict); |
| 1135 | 1138 |
| 1136 SaveQuicServerInfoMapToServerPrefs(quic_server_info_map, | 1139 SaveQuicServerInfoMapToServerPrefs(quic_server_info_map, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 quic_servers_dict); | 1252 quic_servers_dict); |
| 1250 } | 1253 } |
| 1251 | 1254 |
| 1252 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 1255 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 1253 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1256 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 1254 if (!setting_prefs_) | 1257 if (!setting_prefs_) |
| 1255 ScheduleUpdateCacheOnPrefThread(); | 1258 ScheduleUpdateCacheOnPrefThread(); |
| 1256 } | 1259 } |
| 1257 | 1260 |
| 1258 } // namespace net | 1261 } // namespace net |
| OLD | NEW |