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 | 4 |
5 #include "chrome/browser/net/http_server_properties_manager.h" | 5 #include "chrome/browser/net/http_server_properties_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 std::string protocol_str; | 392 std::string protocol_str; |
393 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( | 393 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( |
394 "protocol_str", &protocol_str)) { | 394 "protocol_str", &protocol_str)) { |
395 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 395 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
396 detected_corrupted_prefs = true; | 396 detected_corrupted_prefs = true; |
397 continue; | 397 continue; |
398 } | 398 } |
399 net::AlternateProtocol protocol = | 399 net::AlternateProtocol protocol = |
400 net::AlternateProtocolFromString(protocol_str); | 400 net::AlternateProtocolFromString(protocol_str); |
401 if (protocol > net::NUM_ALTERNATE_PROTOCOLS) { | 401 if (!net::IsAlternateProtocolValid(protocol)) { |
402 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 402 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
403 detected_corrupted_prefs = true; | 403 detected_corrupted_prefs = true; |
404 continue; | 404 continue; |
405 } | 405 } |
406 | 406 |
407 net::PortAlternateProtocolPair port_alternate_protocol; | 407 net::PortAlternateProtocolPair port_alternate_protocol; |
408 port_alternate_protocol.port = port; | 408 port_alternate_protocol.port = port; |
409 port_alternate_protocol.protocol = protocol; | 409 port_alternate_protocol.protocol = protocol; |
410 | 410 |
411 (*alternate_protocol_map)[server] = port_alternate_protocol; | 411 (*alternate_protocol_map)[server] = port_alternate_protocol; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 587 } |
588 } | 588 } |
589 | 589 |
590 // Add AlternateProtocol servers to server_pref_map. | 590 // Add AlternateProtocol servers to server_pref_map. |
591 for (net::AlternateProtocolMap::const_iterator map_it = | 591 for (net::AlternateProtocolMap::const_iterator map_it = |
592 alternate_protocol_map->begin(); | 592 alternate_protocol_map->begin(); |
593 map_it != alternate_protocol_map->end(); ++map_it) { | 593 map_it != alternate_protocol_map->end(); ++map_it) { |
594 const net::HostPortPair& server = map_it->first; | 594 const net::HostPortPair& server = map_it->first; |
595 const net::PortAlternateProtocolPair& port_alternate_protocol = | 595 const net::PortAlternateProtocolPair& port_alternate_protocol = |
596 map_it->second; | 596 map_it->second; |
597 if (port_alternate_protocol.protocol < 0 || | 597 if (!net::IsAlternateProtocolValid(port_alternate_protocol.protocol)) { |
598 port_alternate_protocol.protocol >= net::NUM_ALTERNATE_PROTOCOLS) { | |
599 continue; | 598 continue; |
600 } | 599 } |
601 | 600 |
602 ServerPrefMap::iterator it = server_pref_map.find(server); | 601 ServerPrefMap::iterator it = server_pref_map.find(server); |
603 if (it == server_pref_map.end()) { | 602 if (it == server_pref_map.end()) { |
604 ServerPref server_pref(false, NULL, &map_it->second); | 603 ServerPref server_pref(false, NULL, &map_it->second); |
605 server_pref_map[server] = server_pref; | 604 server_pref_map[server] = server_pref; |
606 } else { | 605 } else { |
607 it->second.alternate_protocol = &map_it->second; | 606 it->second.alternate_protocol = &map_it->second; |
608 } | 607 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 completion.Run(); | 690 completion.Run(); |
692 } | 691 } |
693 | 692 |
694 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 693 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
695 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 694 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
696 if (!setting_prefs_) | 695 if (!setting_prefs_) |
697 ScheduleUpdateCacheOnUI(); | 696 ScheduleUpdateCacheOnUI(); |
698 } | 697 } |
699 | 698 |
700 } // namespace chrome_browser_net | 699 } // namespace chrome_browser_net |
OLD | NEW |