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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
9 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
10 #include "base/stl_util.h" 12 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
13 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "net/base/ip_address.h" 17 #include "net/base/ip_address.h"
16 #include "net/base/port_util.h" 18 #include "net/base/port_util.h"
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 alternative_service_info_vector->empty()) { 1188 alternative_service_info_vector->empty()) {
1187 return; 1189 return;
1188 } 1190 }
1189 std::unique_ptr<base::ListValue> alternative_service_list( 1191 std::unique_ptr<base::ListValue> alternative_service_list(
1190 new base::ListValue); 1192 new base::ListValue);
1191 for (const AlternativeServiceInfo& alternative_service_info : 1193 for (const AlternativeServiceInfo& alternative_service_info :
1192 *alternative_service_info_vector) { 1194 *alternative_service_info_vector) {
1193 const AlternativeService alternative_service = 1195 const AlternativeService alternative_service =
1194 alternative_service_info.alternative_service; 1196 alternative_service_info.alternative_service;
1195 DCHECK(IsAlternateProtocolValid(alternative_service.protocol)); 1197 DCHECK(IsAlternateProtocolValid(alternative_service.protocol));
1196 base::DictionaryValue* alternative_service_dict = new base::DictionaryValue; 1198 std::unique_ptr<base::DictionaryValue> alternative_service_dict(
1199 new base::DictionaryValue);
1197 alternative_service_dict->SetInteger(kPortKey, alternative_service.port); 1200 alternative_service_dict->SetInteger(kPortKey, alternative_service.port);
1198 if (!alternative_service.host.empty()) { 1201 if (!alternative_service.host.empty()) {
1199 alternative_service_dict->SetString(kHostKey, alternative_service.host); 1202 alternative_service_dict->SetString(kHostKey, alternative_service.host);
1200 } 1203 }
1201 alternative_service_dict->SetString( 1204 alternative_service_dict->SetString(
1202 kProtocolKey, AlternateProtocolToString(alternative_service.protocol)); 1205 kProtocolKey, AlternateProtocolToString(alternative_service.protocol));
1203 // JSON cannot store int64_t, so expiration is converted to a string. 1206 // JSON cannot store int64_t, so expiration is converted to a string.
1204 alternative_service_dict->SetString( 1207 alternative_service_dict->SetString(
1205 kExpirationKey, 1208 kExpirationKey,
1206 base::Int64ToString( 1209 base::Int64ToString(
1207 alternative_service_info.expiration.ToInternalValue())); 1210 alternative_service_info.expiration.ToInternalValue()));
1208 alternative_service_list->Append(alternative_service_dict); 1211 alternative_service_list->Append(std::move(alternative_service_dict));
1209 } 1212 }
1210 if (alternative_service_list->GetSize() == 0) 1213 if (alternative_service_list->GetSize() == 0)
1211 return; 1214 return;
1212 server_pref_dict->SetWithoutPathExpansion(kAlternativeServiceKey, 1215 server_pref_dict->SetWithoutPathExpansion(kAlternativeServiceKey,
1213 alternative_service_list.release()); 1216 alternative_service_list.release());
1214 } 1217 }
1215 1218
1216 void HttpServerPropertiesManager::SaveSupportsQuicToPrefs( 1219 void HttpServerPropertiesManager::SaveSupportsQuicToPrefs(
1217 const IPAddress* last_quic_address, 1220 const IPAddress* last_quic_address,
1218 base::DictionaryValue* http_server_properties_dict) { 1221 base::DictionaryValue* http_server_properties_dict) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 quic_servers_dict); 1265 quic_servers_dict);
1263 } 1266 }
1264 1267
1265 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 1268 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
1266 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 1269 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
1267 if (!setting_prefs_) 1270 if (!setting_prefs_)
1268 ScheduleUpdateCacheOnPrefThread(); 1271 ScheduleUpdateCacheOnPrefThread();
1269 } 1272 }
1270 1273
1271 } // namespace net 1274 } // namespace net
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698