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" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "net/base/net_util.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Time to wait before starting an update the http_server_properties_impl_ cache | 22 // Time to wait before starting an update the http_server_properties_impl_ cache |
22 // from preferences. Scheduling another update during this period will reset the | 23 // from preferences. Scheduling another update during this period will reset the |
23 // timer. | 24 // timer. |
24 const int64 kUpdateCacheDelayMs = 1000; | 25 const int64 kUpdateCacheDelayMs = 1000; |
25 | 26 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 "alternate_protocol", &port_alternate_protocol_dict)) { | 413 "alternate_protocol", &port_alternate_protocol_dict)) { |
413 continue; | 414 continue; |
414 } | 415 } |
415 | 416 |
416 if (count >= kMaxAlternateProtocolHostsToPersist) | 417 if (count >= kMaxAlternateProtocolHostsToPersist) |
417 continue; | 418 continue; |
418 do { | 419 do { |
419 int port = 0; | 420 int port = 0; |
420 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( | 421 if (!port_alternate_protocol_dict->GetIntegerWithoutPathExpansion( |
421 "port", &port) || | 422 "port", &port) || |
422 (port > (1 << 16))) { | 423 !IsPortValid(port)) { |
423 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 424 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
424 detected_corrupted_prefs = true; | 425 detected_corrupted_prefs = true; |
425 continue; | 426 continue; |
426 } | 427 } |
427 std::string protocol_str; | 428 std::string protocol_str; |
428 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( | 429 if (!port_alternate_protocol_dict->GetStringWithoutPathExpansion( |
429 "protocol_str", &protocol_str)) { | 430 "protocol_str", &protocol_str)) { |
430 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; | 431 DVLOG(1) << "Malformed Alternate-Protocol server: " << server_str; |
431 detected_corrupted_prefs = true; | 432 detected_corrupted_prefs = true; |
432 continue; | 433 continue; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 completion.Run(); | 790 completion.Run(); |
790 } | 791 } |
791 | 792 |
792 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 793 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
793 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 794 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
794 if (!setting_prefs_) | 795 if (!setting_prefs_) |
795 ScheduleUpdateCacheOnPrefThread(); | 796 ScheduleUpdateCacheOnPrefThread(); |
796 } | 797 } |
797 | 798 |
798 } // namespace net | 799 } // namespace net |
OLD | NEW |