| OLD | NEW |
| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 do { | 330 do { |
| 331 int port = 0; | 331 int port = 0; |
| 332 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | 332 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( |
| 333 "port", &port) || (port > (1 << 16))) { | 333 "port", &port) || (port > (1 << 16))) { |
| 334 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 334 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 335 detected_corrupted_prefs = true; | 335 detected_corrupted_prefs = true; |
| 336 continue; | 336 continue; |
| 337 } | 337 } |
| 338 int protocol = 0; | 338 std::string protocol_str; |
| 339 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | 339 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( |
| 340 "protocol", &protocol) || (protocol < 0) || | 340 "protocol_str", &protocol_str)) { |
| 341 (protocol > net::NUM_ALTERNATE_PROTOCOLS)) { | |
| 342 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 341 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 343 detected_corrupted_prefs = true; | 342 detected_corrupted_prefs = true; |
| 344 continue; | 343 continue; |
| 344 } |
| 345 net::AlternateProtocol protocol = |
| 346 net::AlternateProtocolFromString(protocol_str); |
| 347 if (protocol > net::NUM_ALTERNATE_PROTOCOLS) { |
| 348 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 349 detected_corrupted_prefs = true; |
| 350 continue; |
| 345 } | 351 } |
| 346 | 352 |
| 347 net::PortAlternateProtocolPair port_alternate_protocol; | 353 net::PortAlternateProtocolPair port_alternate_protocol; |
| 348 port_alternate_protocol.port = port; | 354 port_alternate_protocol.port = port; |
| 349 port_alternate_protocol.protocol = static_cast<net::AlternateProtocol>( | 355 port_alternate_protocol.protocol = protocol; |
| 350 protocol); | |
| 351 | 356 |
| 352 (*alternate_protocol_map)[server] = port_alternate_protocol; | 357 (*alternate_protocol_map)[server] = port_alternate_protocol; |
| 353 } while (false); | 358 } while (false); |
| 354 } | 359 } |
| 355 | 360 |
| 356 BrowserThread::PostTask( | 361 BrowserThread::PostTask( |
| 357 BrowserThread::IO, | 362 BrowserThread::IO, |
| 358 FROM_HERE, | 363 FROM_HERE, |
| 359 base::Bind(&HttpServerPropertiesManager:: | 364 base::Bind(&HttpServerPropertiesManager:: |
| 360 UpdateCacheFromPrefsOnIO, | 365 UpdateCacheFromPrefsOnIO, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 587 } |
| 583 | 588 |
| 584 // Save alternate_protocol. | 589 // Save alternate_protocol. |
| 585 if (server_pref.alternate_protocol) { | 590 if (server_pref.alternate_protocol) { |
| 586 base::DictionaryValue* port_alternate_protocol_dict = | 591 base::DictionaryValue* port_alternate_protocol_dict = |
| 587 new base::DictionaryValue; | 592 new base::DictionaryValue; |
| 588 const net::PortAlternateProtocolPair* port_alternate_protocol = | 593 const net::PortAlternateProtocolPair* port_alternate_protocol = |
| 589 server_pref.alternate_protocol; | 594 server_pref.alternate_protocol; |
| 590 port_alternate_protocol_dict->SetInteger( | 595 port_alternate_protocol_dict->SetInteger( |
| 591 "port", port_alternate_protocol->port); | 596 "port", port_alternate_protocol->port); |
| 592 port_alternate_protocol_dict->SetInteger( | 597 const char* protocol_str = |
| 593 "protocol", port_alternate_protocol->protocol); | 598 net::AlternateProtocolToString(port_alternate_protocol->protocol); |
| 599 port_alternate_protocol_dict->SetString("protocol_str", protocol_str); |
| 594 server_pref_dict->SetWithoutPathExpansion( | 600 server_pref_dict->SetWithoutPathExpansion( |
| 595 "alternate_protocol", port_alternate_protocol_dict); | 601 "alternate_protocol", port_alternate_protocol_dict); |
| 596 } | 602 } |
| 597 | 603 |
| 598 if (server_pref.pipeline_capability != net::PIPELINE_UNKNOWN) { | 604 if (server_pref.pipeline_capability != net::PIPELINE_UNKNOWN) { |
| 599 server_pref_dict->SetInteger("pipeline_capability", | 605 server_pref_dict->SetInteger("pipeline_capability", |
| 600 server_pref.pipeline_capability); | 606 server_pref.pipeline_capability); |
| 601 } | 607 } |
| 602 | 608 |
| 603 http_server_properties_dict.SetWithoutPathExpansion(server.ToString(), | 609 http_server_properties_dict.SetWithoutPathExpansion(server.ToString(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 621 std::string* pref_name = content::Details<std::string>(details).ptr(); | 627 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 622 if (*pref_name == prefs::kHttpServerProperties) { | 628 if (*pref_name == prefs::kHttpServerProperties) { |
| 623 if (!setting_prefs_) | 629 if (!setting_prefs_) |
| 624 ScheduleUpdateCacheOnUI(); | 630 ScheduleUpdateCacheOnUI(); |
| 625 } else { | 631 } else { |
| 626 NOTREACHED(); | 632 NOTREACHED(); |
| 627 } | 633 } |
| 628 } | 634 } |
| 629 | 635 |
| 630 } // namespace chrome_browser_net | 636 } // namespace chrome_browser_net |
| OLD | NEW |