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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 4 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 | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/plugin_finder.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 (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/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 const base::DictionaryValue* servers_dict; 247 const base::DictionaryValue* servers_dict;
248 if (version == kMissingVersion) { 248 if (version == kMissingVersion) {
249 // If http_server_properties_dict has no "version" key and no "servers" key, 249 // If http_server_properties_dict has no "version" key and no "servers" key,
250 // then the properties for a given server are in 250 // then the properties for a given server are in
251 // http_server_properties_dict[server]. 251 // http_server_properties_dict[server].
252 servers_dict = &http_server_properties_dict; 252 servers_dict = &http_server_properties_dict;
253 } else { 253 } else {
254 // The "new" format has "version" and "servers" keys. The properties for a 254 // The "new" format has "version" and "servers" keys. The properties for a
255 // given server is in http_server_properties_dict["servers"][server]. 255 // given server is in http_server_properties_dict["servers"][server].
256 base::DictionaryValue* servers_dict_temp = NULL; 256 const base::DictionaryValue* servers_dict_temp = NULL;
257 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion( 257 if (!http_server_properties_dict.GetDictionaryWithoutPathExpansion(
258 "servers", &servers_dict_temp)) { 258 "servers", &servers_dict_temp)) {
259 DVLOG(1) << "Malformed http_server_properties for servers"; 259 DVLOG(1) << "Malformed http_server_properties for servers";
260 return; 260 return;
261 } 261 }
262 servers_dict = servers_dict_temp; 262 servers_dict = servers_dict_temp;
263 } 263 }
264 264
265 // String is host/port pair of spdy server. 265 // String is host/port pair of spdy server.
266 scoped_ptr<StringVector> spdy_servers(new StringVector); 266 scoped_ptr<StringVector> spdy_servers(new StringVector);
267 scoped_ptr<net::SpdySettingsMap> spdy_settings_map(new net::SpdySettingsMap); 267 scoped_ptr<net::SpdySettingsMap> spdy_settings_map(new net::SpdySettingsMap);
268 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map( 268 scoped_ptr<net::PipelineCapabilityMap> pipeline_capability_map(
269 new net::PipelineCapabilityMap); 269 new net::PipelineCapabilityMap);
270 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map( 270 scoped_ptr<net::AlternateProtocolMap> alternate_protocol_map(
271 new net::AlternateProtocolMap); 271 new net::AlternateProtocolMap);
272 272
273 for (base::DictionaryValue::key_iterator it = servers_dict->begin_keys(); 273 for (base::DictionaryValue::key_iterator it = servers_dict->begin_keys();
274 it != servers_dict->end_keys(); 274 it != servers_dict->end_keys();
275 ++it) { 275 ++it) {
276 // Get server's host/pair. 276 // Get server's host/pair.
277 const std::string& server_str = *it; 277 const std::string& server_str = *it;
278 net::HostPortPair server = net::HostPortPair::FromString(server_str); 278 net::HostPortPair server = net::HostPortPair::FromString(server_str);
279 if (server.host().empty()) { 279 if (server.host().empty()) {
280 DVLOG(1) << "Malformed http_server_properties for server: " << server_str; 280 DVLOG(1) << "Malformed http_server_properties for server: " << server_str;
281 detected_corrupted_prefs = true; 281 detected_corrupted_prefs = true;
282 continue; 282 continue;
283 } 283 }
284 284
285 base::DictionaryValue* server_pref_dict = NULL; 285 const base::DictionaryValue* server_pref_dict = NULL;
286 if (!servers_dict->GetDictionaryWithoutPathExpansion( 286 if (!servers_dict->GetDictionaryWithoutPathExpansion(
287 server_str, &server_pref_dict)) { 287 server_str, &server_pref_dict)) {
288 DVLOG(1) << "Malformed http_server_properties server: " << server_str; 288 DVLOG(1) << "Malformed http_server_properties server: " << server_str;
289 detected_corrupted_prefs = true; 289 detected_corrupted_prefs = true;
290 continue; 290 continue;
291 } 291 }
292 292
293 // Get if server supports Spdy. 293 // Get if server supports Spdy.
294 bool supports_spdy = false; 294 bool supports_spdy = false;
295 if ((server_pref_dict->GetBoolean( 295 if ((server_pref_dict->GetBoolean(
296 "supports_spdy", &supports_spdy)) && supports_spdy) { 296 "supports_spdy", &supports_spdy)) && supports_spdy) {
297 spdy_servers->push_back(server_str); 297 spdy_servers->push_back(server_str);
298 } 298 }
299 299
300 // Get SpdySettings. 300 // Get SpdySettings.
301 DCHECK(!ContainsKey(*spdy_settings_map, server)); 301 DCHECK(!ContainsKey(*spdy_settings_map, server));
302 if (version == kVersionNumber) { 302 if (version == kVersionNumber) {
303 base::DictionaryValue* spdy_settings_dict = NULL; 303 const base::DictionaryValue* spdy_settings_dict = NULL;
304 if (server_pref_dict->GetDictionaryWithoutPathExpansion( 304 if (server_pref_dict->GetDictionaryWithoutPathExpansion(
305 "settings", &spdy_settings_dict)) { 305 "settings", &spdy_settings_dict)) {
306 net::SettingsMap settings_map; 306 net::SettingsMap settings_map;
307 for (base::DictionaryValue::key_iterator dict_it = 307 for (base::DictionaryValue::key_iterator dict_it =
308 spdy_settings_dict->begin_keys(); 308 spdy_settings_dict->begin_keys();
309 dict_it != spdy_settings_dict->end_keys(); ++dict_it) { 309 dict_it != spdy_settings_dict->end_keys(); ++dict_it) {
310 const std::string& id_str = *dict_it; 310 const std::string& id_str = *dict_it;
311 int id = 0; 311 int id = 0;
312 if (!base::StringToInt(id_str, &id)) { 312 if (!base::StringToInt(id_str, &id)) {
313 DVLOG(1) << "Malformed id in SpdySettings for server: " << 313 DVLOG(1) << "Malformed id in SpdySettings for server: " <<
(...skipping 20 matching lines...) Expand all
334 int pipeline_capability = net::PIPELINE_UNKNOWN; 334 int pipeline_capability = net::PIPELINE_UNKNOWN;
335 if ((server_pref_dict->GetInteger( 335 if ((server_pref_dict->GetInteger(
336 "pipeline_capability", &pipeline_capability)) && 336 "pipeline_capability", &pipeline_capability)) &&
337 pipeline_capability != net::PIPELINE_UNKNOWN) { 337 pipeline_capability != net::PIPELINE_UNKNOWN) {
338 (*pipeline_capability_map)[server] = 338 (*pipeline_capability_map)[server] =
339 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability); 339 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability);
340 } 340 }
341 341
342 // Get alternate_protocol server. 342 // Get alternate_protocol server.
343 DCHECK(!ContainsKey(*alternate_protocol_map, server)); 343 DCHECK(!ContainsKey(*alternate_protocol_map, server));
344 base::DictionaryValue* port_alternate_protocol_dict = NULL; 344 const base::DictionaryValue* port_alternate_protocol_dict = NULL;
345 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( 345 if (!server_pref_dict->GetDictionaryWithoutPathExpansion(
346 "alternate_protocol", &port_alternate_protocol_dict)) { 346 "alternate_protocol", &port_alternate_protocol_dict)) {
347 continue; 347 continue;
348 } 348 }
349 349
350 do { 350 do {
351 int port = 0; 351 int port = 0;
352 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( 352 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion(
353 "port", &port) || (port > (1 << 16))) { 353 "port", &port) || (port > (1 << 16))) {
354 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; 354 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 std::string* pref_name = content::Details<std::string>(details).ptr(); 647 std::string* pref_name = content::Details<std::string>(details).ptr();
648 if (*pref_name == prefs::kHttpServerProperties) { 648 if (*pref_name == prefs::kHttpServerProperties) {
649 if (!setting_prefs_) 649 if (!setting_prefs_)
650 ScheduleUpdateCacheOnUI(); 650 ScheduleUpdateCacheOnUI();
651 } else { 651 } else {
652 NOTREACHED(); 652 NOTREACHED();
653 } 653 }
654 } 654 }
655 655
656 } // namespace chrome_browser_net 656 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log.cc ('k') | chrome/browser/plugin_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698