| 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_WIN_H_ | 5 #ifndef NET_DNS_DNS_CONFIG_SERVICE_WIN_H_ |
| 6 #define NET_DNS_DNS_CONFIG_SERVICE_WIN_H_ | 6 #define NET_DNS_DNS_CONFIG_SERVICE_WIN_H_ |
| 7 | 7 |
| 8 // The sole purpose of dns_config_service_win.h is for unittests so we just | 8 // The sole purpose of dns_config_service_win.h is for unittests so we just |
| 9 // include these headers here. | 9 // include these headers here. |
| 10 #include <winsock2.h> | 10 #include <winsock2.h> |
| 11 #include <iphlpapi.h> | 11 #include <iphlpapi.h> |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h" |
| 19 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
| 20 #include "net/base/network_change_notifier.h" |
| 20 #include "net/dns/dns_config_service.h" | 21 #include "net/dns/dns_config_service.h" |
| 21 | 22 |
| 22 // The general effort of DnsConfigServiceWin is to configure |nameservers| and | 23 // The general effort of DnsConfigServiceWin is to configure |nameservers| and |
| 23 // |search| in DnsConfig. The settings are stored in the Windows registry, but | 24 // |search| in DnsConfig. The settings are stored in the Windows registry, but |
| 24 // to simplify the task we use the IP Helper API wherever possible. That API | 25 // to simplify the task we use the IP Helper API wherever possible. That API |
| 25 // yields the complete and ordered |nameservers|, but to determine |search| we | 26 // yields the complete and ordered |nameservers|, but to determine |search| we |
| 26 // need to use the registry. On Windows 7, WMI does return the correct |search| | 27 // need to use the registry. On Windows 7, WMI does return the correct |search| |
| 27 // but on earlier versions it is insufficient. | 28 // but on earlier versions it is insufficient. |
| 28 // | 29 // |
| 29 // Experimental evaluation of Windows behavior suggests that domain parsing is | 30 // Experimental evaluation of Windows behavior suggests that domain parsing is |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 DnsConfig* dns_config); | 123 DnsConfig* dns_config); |
| 123 | 124 |
| 124 // Use DnsConfigService::CreateSystemService to use it outside of tests. | 125 // Use DnsConfigService::CreateSystemService to use it outside of tests. |
| 125 class NET_EXPORT_PRIVATE DnsConfigServiceWin | 126 class NET_EXPORT_PRIVATE DnsConfigServiceWin |
| 126 : public DnsConfigService, | 127 : public DnsConfigService, |
| 127 public NetworkChangeNotifier::IPAddressObserver { | 128 public NetworkChangeNotifier::IPAddressObserver { |
| 128 public: | 129 public: |
| 129 DnsConfigServiceWin(); | 130 DnsConfigServiceWin(); |
| 130 virtual ~DnsConfigServiceWin(); | 131 virtual ~DnsConfigServiceWin(); |
| 131 | 132 |
| 132 virtual void Watch(const CallbackType& callback) OVERRIDE; | |
| 133 | |
| 134 private: | 133 private: |
| 134 class Watcher; |
| 135 class ConfigReader; | 135 class ConfigReader; |
| 136 class HostsReader; | 136 class HostsReader; |
| 137 | 137 |
| 138 // NetworkChangeNotifier::DNSObserver: | 138 // DnsConfigService: |
| 139 virtual void OnDNSChanged(unsigned detail) OVERRIDE; | 139 virtual void ReadNow() OVERRIDE; |
| 140 virtual bool StartWatching() OVERRIDE; |
| 140 | 141 |
| 141 // NetworkChangeNotifier::IPAddressObserver: | 142 // NetworkChangeNotifier::IPAddressObserver: |
| 142 virtual void OnIPAddressChanged() OVERRIDE; | 143 virtual void OnIPAddressChanged() OVERRIDE; |
| 143 | 144 |
| 145 void OnConfigChanged(bool succeeded); |
| 146 void OnHostsChanged(bool succeeded); |
| 147 |
| 148 scoped_ptr<Watcher> watcher_; |
| 144 scoped_refptr<ConfigReader> config_reader_; | 149 scoped_refptr<ConfigReader> config_reader_; |
| 145 scoped_refptr<HostsReader> hosts_reader_; | 150 scoped_refptr<HostsReader> hosts_reader_; |
| 146 | 151 |
| 147 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceWin); | 152 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceWin); |
| 148 }; | 153 }; |
| 149 | 154 |
| 150 } // namespace internal | 155 } // namespace internal |
| 151 | 156 |
| 152 } // namespace net | 157 } // namespace net |
| 153 | 158 |
| 154 #endif // NET_DNS_DNS_CONFIG_SERVICE_WIN_H_ | 159 #endif // NET_DNS_DNS_CONFIG_SERVICE_WIN_H_ |
| 155 | 160 |
| OLD | NEW |