Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/http/http_server_properties_manager.h" | 5 #include "net/http/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/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 "alternate_protocol", &port_alternate_protocol_dict)) { | 412 "alternate_protocol", &port_alternate_protocol_dict)) { |
| 413 continue; | 413 continue; |
| 414 } | 414 } |
| 415 | 415 |
| 416 if (count >= kMaxAlternateProtocolHostsToPersist) | 416 if (count >= kMaxAlternateProtocolHostsToPersist) |
| 417 continue; | 417 continue; |
| 418 do { | 418 do { |
| 419 int port = 0; | 419 int port = 0; |
| 420 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | 420 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( |
| 421 "port", &port) || | 421 "port", &port) || |
| 422 (port > (1 << 16))) { | 422 (port > std::numeric_limits<uint16>::max())) { |
| 423 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 423 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 424 detected_corrupted_prefs = true; | 424 detected_corrupted_prefs = true; |
| 425 continue; | 425 continue; |
| 426 } | 426 } |
| 427 std::string protocol_str; | 427 std::string protocol_str; |
| 428 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( | 428 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( |
| 429 "protocol_str", &protocol_str)) { | 429 "protocol_str", &protocol_str)) { |
| 430 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 430 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 431 detected_corrupted_prefs = true; | 431 detected_corrupted_prefs = true; |
| 432 continue; | 432 continue; |
| 433 } | 433 } |
| 434 net::AlternateProtocol protocol = | 434 net::AlternateProtocol protocol = |
| 435 net::AlternateProtocolFromString(protocol_str); | 435 net::AlternateProtocolFromString(protocol_str); |
| 436 if (!net::IsAlternateProtocolValid(protocol)) { | 436 if (!net::IsAlternateProtocolValid(protocol)) { |
| 437 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 437 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 438 detected_corrupted_prefs = true; | 438 detected_corrupted_prefs = true; |
| 439 continue; | 439 continue; |
| 440 } | 440 } |
| 441 | 441 |
| 442 double probability = 1; | 442 double probability = 1; |
| 443 if (port_alternate_protocol_dict->HasKey("probability") && | 443 if (port_alternate_protocol_dict->HasKey("probability") && |
| 444 !port_alternate_protocol_dict->GetDoubleWithoutPathExpansion( | 444 !port_alternate_protocol_dict->GetDoubleWithoutPathExpansion( |
| 445 "probability", &probability)) { | 445 "probability", &probability)) { |
| 446 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 446 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
| 447 detected_corrupted_prefs = true; | 447 detected_corrupted_prefs = true; |
| 448 continue; | 448 continue; |
| 449 } | 449 } |
| 450 | 450 |
| 451 net::AlternateProtocolInfo port_alternate_protocol(port, | 451 net::AlternateProtocolInfo port_alternate_protocol( |
| 452 protocol, | 452 static_cast<uint16>(port), protocol, probability); |
|
mmenke
2014/11/18 21:06:39
Should include basictypes.h
Peter Kasting
2014/11/18 23:38:42
In this file's header file.
| |
| 453 probability); | |
| 454 alternate_protocol_map->Put(server, port_alternate_protocol); | 453 alternate_protocol_map->Put(server, port_alternate_protocol); |
| 455 ++count; | 454 ++count; |
| 456 } while (false); | 455 } while (false); |
| 457 | 456 |
| 458 // Get SupportsQuic. | 457 // Get SupportsQuic. |
| 459 DCHECK(supports_quic_map->find(server) == supports_quic_map->end()); | 458 DCHECK(supports_quic_map->find(server) == supports_quic_map->end()); |
| 460 const base::DictionaryValue* supports_quic_dict = NULL; | 459 const base::DictionaryValue* supports_quic_dict = NULL; |
| 461 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( | 460 if (!server_pref_dict->GetDictionaryWithoutPathExpansion( |
| 462 "supports_quic", &supports_quic_dict)) { | 461 "supports_quic", &supports_quic_dict)) { |
| 463 continue; | 462 continue; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 completion.Run(); | 788 completion.Run(); |
| 790 } | 789 } |
| 791 | 790 |
| 792 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 791 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
| 793 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 792 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
| 794 if (!setting_prefs_) | 793 if (!setting_prefs_) |
| 795 ScheduleUpdateCacheOnPrefThread(); | 794 ScheduleUpdateCacheOnPrefThread(); |
| 796 } | 795 } |
| 797 | 796 |
| 798 } // namespace net | 797 } // namespace net |
| OLD | NEW |