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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 if (detected_corrupted_prefs) | 774 if (detected_corrupted_prefs) |
775 ScheduleUpdatePrefsOnNetworkThread(DETECTED_CORRUPTED_PREFS); | 775 ScheduleUpdatePrefsOnNetworkThread(DETECTED_CORRUPTED_PREFS); |
776 } | 776 } |
777 | 777 |
778 // | 778 // |
779 // Update Preferences with data from the cached data. | 779 // Update Preferences with data from the cached data. |
780 // | 780 // |
781 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread( | 781 void HttpServerPropertiesManager::ScheduleUpdatePrefsOnNetworkThread( |
782 Location location) { | 782 Location location) { |
783 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 783 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
784 // Cancel pending updates, if any. | 784 // Do not schedule a new update if there is already one scheduled. |
785 network_prefs_update_timer_->Stop(); | 785 if (network_prefs_update_timer_->IsRunning()) |
| 786 return; |
| 787 |
786 StartPrefsUpdateTimerOnNetworkThread( | 788 StartPrefsUpdateTimerOnNetworkThread( |
787 base::TimeDelta::FromMilliseconds(kUpdatePrefsDelayMs)); | 789 base::TimeDelta::FromMilliseconds(kUpdatePrefsDelayMs)); |
788 // TODO(rtenneti): Delete the following histogram after collecting some data. | 790 // TODO(rtenneti): Delete the following histogram after collecting some data. |
789 UMA_HISTOGRAM_ENUMERATION("Net.HttpServerProperties.UpdatePrefs", location, | 791 UMA_HISTOGRAM_ENUMERATION("Net.HttpServerProperties.UpdatePrefs", location, |
790 HttpServerPropertiesManager::NUM_LOCATIONS); | 792 HttpServerPropertiesManager::NUM_LOCATIONS); |
791 } | 793 } |
792 | 794 |
793 void HttpServerPropertiesManager::StartPrefsUpdateTimerOnNetworkThread( | 795 void HttpServerPropertiesManager::StartPrefsUpdateTimerOnNetworkThread( |
794 base::TimeDelta delay) { | 796 base::TimeDelta delay) { |
795 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); | 797 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 quic_servers_dict); | 1119 quic_servers_dict); |
1118 } | 1120 } |
1119 | 1121 |
1120 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { | 1122 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { |
1121 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); | 1123 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); |
1122 if (!setting_prefs_) | 1124 if (!setting_prefs_) |
1123 ScheduleUpdateCacheOnPrefThread(); | 1125 ScheduleUpdateCacheOnPrefThread(); |
1124 } | 1126 } |
1125 | 1127 |
1126 } // namespace net | 1128 } // namespace net |
OLD | NEW |