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

Side by Side Diff: chrome/browser/net/http_server_properties_manager.cc

Issue 12601006: Removing base::DictionaryValue::key_iterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch. Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/net/http_server_properties_manager.h" 4 #include "chrome/browser/net/http_server_properties_manager.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 275
276 // String is host/port pair of spdy server. 276 // String is host/port pair of spdy server.
277 scoped_ptr<StringVector> spdy_servers(new StringVector); 277 scoped_ptr<StringVector> spdy_servers(new StringVector);
278 scoped_ptr<net::SpdySettingsMap> spdy_settings_map(new net::SpdySettingsMap); 278 scoped_ptr<net::SpdySettingsMap> spdy_settings_map(new net::SpdySettingsMap);
279 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map( 279 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map(
280 new net::PipelineCapabilityMap); 280 new net::PipelineCapabilityMap);
281 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( 281 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map(
282 new net::AlternateProtocolMap); 282 new net::AlternateProtocolMap);
283 283
284 for (base::DictionaryValue::key_iterator it = servers_dict->begin_keys(); 284 for (base::DictionaryValue::Iterator it(*servers_dict); !it.IsAtEnd();
285 it != servers_dict->end_keys(); 285 it.Advance()) {
286 ++it) {
287 // Get server's host/pair. 286 // Get server's host/pair.
288 const std::string& server_str = *it; 287 const std::string& server_str = it.key();
289 net::HostPortPair server = net::HostPortPair::FromString(server_str); 288 net::HostPortPair server = net::HostPortPair::FromString(server_str);
290 if (server.host().empty()) { 289 if (server.host().empty()) {
291 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; 290 DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
292 detected_corrupted_prefs = true; 291 detected_corrupted_prefs = true;
293 continue; 292 continue;
294 } 293 }
295 294
296 const base::DictionaryValue* server_pref_dict = NULL; 295 const base::DictionaryValue* server_pref_dict = NULL;
297 if (!servers_dict->GetDictionaryWithoutPathExpansion( 296 if (!it.value().GetAsDictionary(&server_pref_dict)) {
298 server_str, &server_pref_dict)) {
299 DVLOG(1) << "Malformed http_server_properties server: " << server_str; 297 DVLOG(1) << "Malformed http_server_properties server: " << server_str;
300 detected_corrupted_prefs = true; 298 detected_corrupted_prefs = true;
301 continue; 299 continue;
302 } 300 }
303 301
304 // Get if server supports Spdy. 302 // Get if server supports Spdy.
305 bool supports_spdy = false; 303 bool supports_spdy = false;
306 if ((server_pref_dict->GetBoolean( 304 if ((server_pref_dict->GetBoolean(
307 "supports_spdy", &supports_spdy)) && supports_spdy) { 305 "supports_spdy", &supports_spdy)) && supports_spdy) {
308 spdy_servers->push_back(server_str); 306 spdy_servers->push_back(server_str);
309 } 307 }
310 308
311 // Get SpdySettings. 309 // Get SpdySettings.
312 DCHECK(!ContainsKey(*spdy_settings_map, server)); 310 DCHECK(!ContainsKey(*spdy_settings_map, server));
313 if (version == kVersionNumber) { 311 if (version == kVersionNumber) {
314 const base::DictionaryValue* spdy_settings_dict = NULL; 312 const base::DictionaryValue* spdy_settings_dict = NULL;
315 if (server_pref_dict->GetDictionaryWithoutPathExpansion( 313 if (server_pref_dict->GetDictionaryWithoutPathExpansion(
316 "settings", &spdy_settings_dict)) { 314 "settings", &spdy_settings_dict)) {
317 net::SettingsMap settings_map; 315 net::SettingsMap settings_map;
318 for (base::DictionaryValue::key_iterator dict_it = 316 for (base::DictionaryValue::Iterator dict_it(*spdy_settings_dict);
319 spdy_settings_dict->begin_keys(); 317 !dict_it.IsAtEnd(); dict_it.Advance()) {
320 dict_it != spdy_settings_dict->end_keys(); ++dict_it) { 318 const std::string& id_str = dict_it.key();
321 const std::string& id_str = *dict_it;
322 int id = 0; 319 int id = 0;
323 if (!base::StringToInt(id_str, &id)) { 320 if (!base::StringToInt(id_str, &id)) {
324 DVLOG(1) << "Malformed id in SpdySettings for server: " << 321 DVLOG(1) << "Malformed id in SpdySettings for server: " <<
325 server_str; 322 server_str;
326 NOTREACHED(); 323 NOTREACHED();
327 continue; 324 continue;
328 } 325 }
329 int value = 0; 326 int value = 0;
330 if (!spdy_settings_dict->GetIntegerWithoutPathExpansion(id_str, 327 if (!dict_it.value().GetAsInteger(&value)) {
331 &value)) {
332 DVLOG(1) << "Malformed value in SpdySettings for server: " << 328 DVLOG(1) << "Malformed value in SpdySettings for server: " <<
333 server_str; 329 server_str;
334 NOTREACHED(); 330 NOTREACHED();
335 continue; 331 continue;
336 } 332 }
337 net::SettingsFlagsAndValue flags_and_value( 333 net::SettingsFlagsAndValue flags_and_value(
338 net::SETTINGS_FLAG_PERSISTED, value); 334 net::SETTINGS_FLAG_PERSISTED, value);
339 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value; 335 settings_map[static_cast<net::SpdySettingsIds>(id)] = flags_and_value;
340 } 336 }
341 (*spdy_settings_map)[server] = settings_map; 337 (*spdy_settings_map)[server] = settings_map;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 completion.Run(); 664 completion.Run();
669 } 665 }
670 666
671 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 667 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
672 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
673 if (!setting_prefs_) 669 if (!setting_prefs_)
674 ScheduleUpdateCacheOnUI(); 670 ScheduleUpdateCacheOnUI();
675 } 671 }
676 672
677 } // namespace chrome_browser_net 673 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/net/transport_security_persister.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698