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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
18 // Needed on shared build with MSVS2010 to avoid multiple definitions of | 18 // Needed on shared build with MSVS2010 to avoid multiple definitions of |
19 // std::vector<IPEndPoint>. | 19 // std::vector<IPEndPoint>. |
20 #include "net/base/address_list.h" | 20 #include "net/base/address_list.h" |
21 #include "net/base/ip_endpoint.h" // win requires size of IPEndPoint | 21 #include "net/base/ip_endpoint.h" // win requires size of IPEndPoint |
22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
23 #include "net/dns/dns_hosts.h" | 23 #include "net/dns/dns_hosts.h" |
24 | 24 |
25 namespace base { | 25 namespace base { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 bool edns0; | 85 bool edns0; |
86 | 86 |
87 // Indicates system configuration uses local IPv6 connectivity, e.g., | 87 // Indicates system configuration uses local IPv6 connectivity, e.g., |
88 // DirectAccess. This is exposed for HostResolver to skip IPv6 probes, | 88 // DirectAccess. This is exposed for HostResolver to skip IPv6 probes, |
89 // as it may cause them to return incorrect results. | 89 // as it may cause them to return incorrect results. |
90 bool use_local_ipv6; | 90 bool use_local_ipv6; |
91 }; | 91 }; |
92 | 92 |
93 // Service for reading system DNS settings, on demand or when signalled by | 93 // Service for reading system DNS settings, on demand or when signalled by |
94 // internal watchers and NetworkChangeNotifier. | 94 // internal watchers and NetworkChangeNotifier. |
95 class NET_EXPORT_PRIVATE DnsConfigService | 95 class NET_EXPORT_PRIVATE DnsConfigService { |
96 : NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
97 public: | 96 public: |
98 // Callback interface for the client, called on the same thread as | 97 // Callback interface for the client, called on the same thread as |
99 // ReadConfig() and WatchConfig(). | 98 // ReadConfig() and WatchConfig(). |
100 typedef base::Callback<void(const DnsConfig& config)> CallbackType; | 99 typedef base::Callback<void(const DnsConfig& config)> CallbackType; |
101 | 100 |
102 // Creates the platform-specific DnsConfigService. | 101 // Creates the platform-specific DnsConfigService. |
103 static std::unique_ptr<DnsConfigService> CreateSystemService(); | 102 static std::unique_ptr<DnsConfigService> CreateSystemService(); |
104 | 103 |
105 DnsConfigService(); | 104 DnsConfigService(); |
106 virtual ~DnsConfigService(); | 105 virtual ~DnsConfigService(); |
(...skipping 28 matching lines...) Expand all Loading... |
135 // Called when the current hosts have changed. | 134 // Called when the current hosts have changed. |
136 void InvalidateHosts(); | 135 void InvalidateHosts(); |
137 | 136 |
138 // Called with new config. |config|.hosts is ignored. | 137 // Called with new config. |config|.hosts is ignored. |
139 void OnConfigRead(const DnsConfig& config); | 138 void OnConfigRead(const DnsConfig& config); |
140 // Called with new hosts. Rest of the config is assumed unchanged. | 139 // Called with new hosts. Rest of the config is assumed unchanged. |
141 void OnHostsRead(const DnsHosts& hosts); | 140 void OnHostsRead(const DnsHosts& hosts); |
142 | 141 |
143 void set_watch_failed(bool value) { watch_failed_ = value; } | 142 void set_watch_failed(bool value) { watch_failed_ = value; } |
144 | 143 |
| 144 THREAD_CHECKER(thread_checker_); |
| 145 |
145 private: | 146 private: |
146 // The timer counts from the last Invalidate* until complete config is read. | 147 // The timer counts from the last Invalidate* until complete config is read. |
147 void StartTimer(); | 148 void StartTimer(); |
148 void OnTimeout(); | 149 void OnTimeout(); |
149 // Called when the config becomes complete. Stops the timer. | 150 // Called when the config becomes complete. Stops the timer. |
150 void OnCompleteConfig(); | 151 void OnCompleteConfig(); |
151 | 152 |
152 CallbackType callback_; | 153 CallbackType callback_; |
153 | 154 |
154 DnsConfig dns_config_; | 155 DnsConfig dns_config_; |
(...skipping 18 matching lines...) Expand all Loading... |
173 | 174 |
174 // Started in Invalidate*, cleared in On*Read. | 175 // Started in Invalidate*, cleared in On*Read. |
175 base::OneShotTimer timer_; | 176 base::OneShotTimer timer_; |
176 | 177 |
177 DISALLOW_COPY_AND_ASSIGN(DnsConfigService); | 178 DISALLOW_COPY_AND_ASSIGN(DnsConfigService); |
178 }; | 179 }; |
179 | 180 |
180 } // namespace net | 181 } // namespace net |
181 | 182 |
182 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_ | 183 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_ |
OLD | NEW |