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

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

Issue 9703050: SPDY - don't persist SpdySettings until we convert it to a map. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 continue; 271 continue;
272 } 272 }
273 273
274 // Get if server supports Spdy. 274 // Get if server supports Spdy.
275 bool supports_spdy = false; 275 bool supports_spdy = false;
276 if ((server_pref_dict->GetBoolean( 276 if ((server_pref_dict->GetBoolean(
277 "supports_spdy", &supports_spdy)) && supports_spdy) { 277 "supports_spdy", &supports_spdy)) && supports_spdy) {
278 spdy_servers->push_back(server_str); 278 spdy_servers->push_back(server_str);
279 } 279 }
280 280
281 // Get SpdySettings. 281 // TODO(rtenneti): Implement reading of SpdySettings.
282 DCHECK(!ContainsKey(*spdy_settings_map, server)); 282 DCHECK(!ContainsKey(*spdy_settings_map, server));
283 base::ListValue* spdy_settings_list = NULL;
284 if (server_pref_dict->GetListWithoutPathExpansion(
285 "settings", &spdy_settings_list)) {
286 spdy::SpdySettings spdy_settings;
287
288 for (base::ListValue::const_iterator list_it =
289 spdy_settings_list->begin();
290 list_it != spdy_settings_list->end(); ++list_it) {
291 if ((*list_it)->GetType() != Value::TYPE_DICTIONARY) {
292 DVLOG(1) << "Malformed SpdySettingsList for server: " << server_str;
293 detected_corrupted_prefs = true;
294 continue;
295 }
296
297 const base::DictionaryValue* spdy_setting_dict =
298 static_cast<const base::DictionaryValue*>(*list_it);
299
300 int id = 0;
301 if (!spdy_setting_dict->GetIntegerWithoutPathExpansion("id", &id)) {
302 DVLOG(1) << "Malformed id in SpdySettings for server: " << server_str;
303 detected_corrupted_prefs = true;
304 continue;
305 }
306
307 int value = 0;
308 if (!spdy_setting_dict->GetIntegerWithoutPathExpansion("value",
309 &value)) {
310 DVLOG(1) << "Malformed value in SpdySettings for server: " <<
311 server_str;
312 detected_corrupted_prefs = true;
313 continue;
314 }
315
316 spdy::SettingsFlagsAndId flags_and_id(
317 spdy::SETTINGS_FLAG_PERSISTED, id);
318 spdy_settings.push_back(spdy::SpdySetting(flags_and_id, value));
319 }
320
321 (*spdy_settings_map)[server] = spdy_settings;
322 }
323 283
324 int pipeline_capability = net::PIPELINE_UNKNOWN; 284 int pipeline_capability = net::PIPELINE_UNKNOWN;
325 if ((server_pref_dict->GetInteger( 285 if ((server_pref_dict->GetInteger(
326 "pipeline_capability", &pipeline_capability)) && 286 "pipeline_capability", &pipeline_capability)) &&
327 pipeline_capability != net::PIPELINE_UNKNOWN) { 287 pipeline_capability != net::PIPELINE_UNKNOWN) {
328 (*pipeline_capability_map)[server] = 288 (*pipeline_capability_map)[server] =
329 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability); 289 static_cast<net::HttpPipelinedHostCapability>(pipeline_capability);
330 } 290 }
331 291
332 // Get alternate_protocol server. 292 // Get alternate_protocol server.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 server_pref_map.begin(); 528 server_pref_map.begin();
569 map_it != server_pref_map.end(); ++map_it) { 529 map_it != server_pref_map.end(); ++map_it) {
570 const net::HostPortPair& server = map_it->first; 530 const net::HostPortPair& server = map_it->first;
571 const ServerPref& server_pref = map_it->second; 531 const ServerPref& server_pref = map_it->second;
572 532
573 base::DictionaryValue* server_pref_dict = new base::DictionaryValue; 533 base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
574 534
575 // Save supports_spdy. 535 // Save supports_spdy.
576 server_pref_dict->SetBoolean("supports_spdy", server_pref.supports_spdy); 536 server_pref_dict->SetBoolean("supports_spdy", server_pref.supports_spdy);
577 537
578 // Save SpdySettings. 538 // TODO(rtenneti): Implement save SpdySettings.
579 if (server_pref.settings) {
580 base::ListValue* spdy_settings_list = new ListValue();
581 for (spdy::SpdySettings::const_iterator it =
582 server_pref.settings->begin();
583 it != server_pref.settings->end(); ++it) {
584 uint32 id = it->first.id();
585 uint32 value = it->second;
586 base::DictionaryValue* spdy_setting_dict = new base::DictionaryValue;
587 spdy_setting_dict->SetInteger("id", id);
588 spdy_setting_dict->SetInteger("value", value);
589 spdy_settings_list->Append(spdy_setting_dict);
590 }
591 server_pref_dict->Set("settings", spdy_settings_list);
592 }
593 539
594 // Save alternate_protocol. 540 // Save alternate_protocol.
595 if (server_pref.alternate_protocol) { 541 if (server_pref.alternate_protocol) {
596 base::DictionaryValue* port_alternate_protocol_dict = 542 base::DictionaryValue* port_alternate_protocol_dict =
597 new base::DictionaryValue; 543 new base::DictionaryValue;
598 const net::PortAlternateProtocolPair* port_alternate_protocol = 544 const net::PortAlternateProtocolPair* port_alternate_protocol =
599 server_pref.alternate_protocol; 545 server_pref.alternate_protocol;
600 port_alternate_protocol_dict->SetInteger( 546 port_alternate_protocol_dict->SetInteger(
601 "port", port_alternate_protocol->port); 547 "port", port_alternate_protocol->port);
602 port_alternate_protocol_dict->SetInteger( 548 port_alternate_protocol_dict->SetInteger(
(...skipping 28 matching lines...) Expand all
631 std::string* pref_name = content::Details<std::string>(details).ptr(); 577 std::string* pref_name = content::Details<std::string>(details).ptr();
632 if (*pref_name == prefs::kHttpServerProperties) { 578 if (*pref_name == prefs::kHttpServerProperties) {
633 if (!setting_prefs_) 579 if (!setting_prefs_)
634 ScheduleUpdateCacheOnUI(); 580 ScheduleUpdateCacheOnUI();
635 } else { 581 } else {
636 NOTREACHED(); 582 NOTREACHED();
637 } 583 }
638 } 584 }
639 585
640 } // namespace chrome_browser_net 586 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/http_server_properties_manager_unittest.cc » ('j') | net/spdy/spdy_session.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698