| 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 #ifndef NET_DNS_DNS_CONFIG_SERVICE_H_ | 5 #ifndef NET_DNS_DNS_CONFIG_SERVICE_H_ |
| 6 #define NET_DNS_DNS_CONFIG_SERVICE_H_ | 6 #define NET_DNS_DNS_CONFIG_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Can be called at most once. | 96 // Can be called at most once. |
| 97 void Read(const CallbackType& callback); | 97 void Read(const CallbackType& callback); |
| 98 | 98 |
| 99 // Registers for notifications at NetworkChangeNotifier. Will attempt to read | 99 // Registers for notifications at NetworkChangeNotifier. Will attempt to read |
| 100 // config after watch is started by NetworkChangeNotifier. Will run |callback| | 100 // config after watch is started by NetworkChangeNotifier. Will run |callback| |
| 101 // iff config changes from last call or should be withdrawn. | 101 // iff config changes from last call or should be withdrawn. |
| 102 // Can be called at most once. | 102 // Can be called at most once. |
| 103 virtual void Watch(const CallbackType& callback); | 103 virtual void Watch(const CallbackType& callback); |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 friend class DnsHostsReader; | |
| 107 | |
| 108 // Called when the current config (except hosts) has changed. | 106 // Called when the current config (except hosts) has changed. |
| 109 void InvalidateConfig(); | 107 void InvalidateConfig(); |
| 110 // Called when the current hosts have changed. | 108 // Called when the current hosts have changed. |
| 111 void InvalidateHosts(); | 109 void InvalidateHosts(); |
| 112 | 110 |
| 113 // Called with new config. |config|.hosts is ignored. | 111 // Called with new config. |config|.hosts is ignored. |
| 114 void OnConfigRead(const DnsConfig& config); | 112 void OnConfigRead(const DnsConfig& config); |
| 115 // Called with new hosts. Rest of the config is assumed unchanged. | 113 // Called with new hosts. Rest of the config is assumed unchanged. |
| 116 void OnHostsRead(const DnsHosts& hosts); | 114 void OnHostsRead(const DnsHosts& hosts); |
| 117 | 115 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 | 130 |
| 133 // True after the first valid DnsConfig is received. Temporary, used | 131 // True after the first valid DnsConfig is received. Temporary, used |
| 134 // to detect DNS-changer: http://crbug.com/125599 | 132 // to detect DNS-changer: http://crbug.com/125599 |
| 135 bool checked_rogue_dns_; | 133 bool checked_rogue_dns_; |
| 136 // True after On*Read, before Invalidate*. Tells if the config is complete. | 134 // True after On*Read, before Invalidate*. Tells if the config is complete. |
| 137 bool have_config_; | 135 bool have_config_; |
| 138 bool have_hosts_; | 136 bool have_hosts_; |
| 139 // True if receiver needs to be updated when the config becomes complete. | 137 // True if receiver needs to be updated when the config becomes complete. |
| 140 bool need_update_; | 138 bool need_update_; |
| 141 // True if the last config sent was empty (instead of |dns_config_|). | 139 // True if the last config sent was empty (instead of |dns_config_|). |
| 140 // Set when |timer_| expires. |
| 142 bool last_sent_empty_; | 141 bool last_sent_empty_; |
| 143 | 142 |
| 143 // Initialized and updated on Invalidate* call. |
| 144 base::TimeTicks last_invalidate_config_time_; |
| 145 base::TimeTicks last_invalidate_hosts_time_; |
| 146 // Initialized and updated when |timer_| expires. |
| 147 base::TimeTicks last_sent_empty_time_; |
| 148 |
| 144 // Started in Invalidate*, cleared in On*Read. | 149 // Started in Invalidate*, cleared in On*Read. |
| 145 base::OneShotTimer<DnsConfigService> timer_; | 150 base::OneShotTimer<DnsConfigService> timer_; |
| 146 | 151 |
| 147 DISALLOW_COPY_AND_ASSIGN(DnsConfigService); | 152 DISALLOW_COPY_AND_ASSIGN(DnsConfigService); |
| 148 }; | 153 }; |
| 149 | 154 |
| 150 } // namespace net | 155 } // namespace net |
| 151 | 156 |
| 152 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_ | 157 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_ |
| OLD | NEW |