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_POSIX_H_ | 5 #ifndef NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_ |
6 #define NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_ | 6 #define NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <netinet/in.h> | 10 #include <netinet/in.h> |
11 #include <resolv.h> | 11 #include <resolv.h> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/dns/dns_config_service.h" | 16 #include "net/dns/dns_config_service.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 class FilePathWatcherWrapper; | |
21 | |
22 // Use DnsConfigService::CreateSystemService to use it outside of tests. | 20 // Use DnsConfigService::CreateSystemService to use it outside of tests. |
23 namespace internal { | 21 namespace internal { |
24 | 22 |
25 class NET_EXPORT_PRIVATE DnsConfigServicePosix | 23 class NET_EXPORT_PRIVATE DnsConfigServicePosix : public DnsConfigService { |
26 : NON_EXPORTED_BASE(public DnsConfigService) { | |
27 public: | 24 public: |
28 DnsConfigServicePosix(); | 25 DnsConfigServicePosix(); |
29 virtual ~DnsConfigServicePosix(); | 26 virtual ~DnsConfigServicePosix(); |
30 | 27 |
31 virtual void Watch(const CallbackType& callback) OVERRIDE; | |
32 | |
33 private: | 28 private: |
34 class ConfigWatcher; | 29 // NetworkChangeNotifier::DNSObserver: |
35 | 30 virtual void OnDNSChanged(unsigned detail) OVERRIDE; |
36 void OnConfigChanged(bool watch_succeeded); | |
37 void OnHostsChanged(bool watch_succeeded); | |
38 | |
39 scoped_ptr<ConfigWatcher> config_watcher_; | |
40 scoped_ptr<FilePathWatcherWrapper> hosts_watcher_; | |
41 | 31 |
42 scoped_refptr<SerialWorker> config_reader_; | 32 scoped_refptr<SerialWorker> config_reader_; |
43 scoped_refptr<SerialWorker> hosts_reader_; | 33 scoped_refptr<SerialWorker> hosts_reader_; |
44 | 34 |
45 DISALLOW_COPY_AND_ASSIGN(DnsConfigServicePosix); | 35 DISALLOW_COPY_AND_ASSIGN(DnsConfigServicePosix); |
46 }; | 36 }; |
47 | 37 |
48 // Fills in |dns_config| from |res|. | 38 // Fills in |dns_config| from |res|. |
49 bool NET_EXPORT_PRIVATE ConvertResStateToDnsConfig( | 39 bool NET_EXPORT_PRIVATE ConvertResStateToDnsConfig( |
50 const struct __res_state& res, DnsConfig* dns_config); | 40 const struct __res_state& res, DnsConfig* dns_config); |
51 | 41 |
52 } // namespace internal | 42 } // namespace internal |
53 | 43 |
54 } // namespace net | 44 } // namespace net |
55 | 45 |
56 #endif // NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_ | 46 #endif // NET_DNS_DNS_CONFIG_SERVICE_POSIX_H_ |
OLD | NEW |