Chromium Code Reviews| Index: net/dns/dns_config_service_posix.cc |
| diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc |
| index b3977fceca0ed6112ce0e391d2cbb8f7af2a007a..0fdd1fe0ed515687a0dcb3f3f658a8d297b9aa1f 100644 |
| --- a/net/dns/dns_config_service_posix.cc |
| +++ b/net/dns/dns_config_service_posix.cc |
| @@ -16,6 +16,10 @@ |
| #include "net/dns/file_path_watcher_wrapper.h" |
| #include "net/dns/serial_worker.h" |
| +#if defined(OS_MACOSX) |
| +#include "net/dns/notify_watcher_mac.h" |
| +#endif |
| + |
| #ifndef _PATH_RESCONF // Normally defined in <resolv.h> |
| #define _PATH_RESCONF "/etc/resolv.conf" |
| #endif |
| @@ -24,7 +28,6 @@ namespace net { |
| namespace { |
| -const FilePath::CharType* kFilePathConfig = FILE_PATH_LITERAL(_PATH_RESCONF); |
| const FilePath::CharType* kFilePathHosts = FILE_PATH_LITERAL("/etc/hosts"); |
| // A SerialWorker that uses libresolv to initialize res_state and converts |
| @@ -82,8 +85,30 @@ class ConfigReader : public SerialWorker { |
| namespace internal { |
| +#if defined(OS_MACOSX) |
| +// Normally defined in dnsinfo.h in configd. |
|
Mark Mentovai
2012/04/17 19:53:54
You can do this:
extern "C" {
// From 10.7.3 con
szym
2012/04/17 20:14:31
I wish this worked. Unfortunately, it won't link (
Mark Mentovai
2012/04/17 20:22:20
szym wrote:
|
| +const char* kDnsNotifyKey = |
|
Mark Mentovai
2012/04/17 19:53:54
If you’re sticking with a const char*, make it sta
|
| + "com.apple.system.SystemConfiguration.dns_configuration"; |
| + |
| +class DnsConfigServicePosix::ConfigWatcher : public NotifyWatcherMac { |
| + public: |
| + bool Watch(const base::Callback<void(bool succeeded)>& callback) { |
| + return NotifyWatcherMac::Watch(kDnsNotifyKey, callback); |
| + } |
| +}; |
| +#else |
| +const FilePath::CharType* kFilePathConfig = FILE_PATH_LITERAL(_PATH_RESCONF); |
|
Mark Mentovai
2012/04/17 19:53:54
This, too, can be static or in an anonymous namesp
|
| + |
| +class DnsConfigServicePosix::ConfigWatcher : public FilePathWatcherWrapper { |
| + public: |
| + bool Watch(const base::Callback<void(bool succeeded)>& callback) { |
| + return FilePathWatcherWrapper:Watch(FilePath(kFilePathConfig), callback); |
| + } |
| +}; |
| +#endif |
| + |
| DnsConfigServicePosix::DnsConfigServicePosix() |
| - : config_watcher_(new FilePathWatcherWrapper()), |
| + : config_watcher_(new ConfigWatcher()), |
| hosts_watcher_(new FilePathWatcherWrapper()) { |
| config_reader_ = new ConfigReader( |
| base::Bind(&DnsConfigServicePosix::OnConfigRead, |
| @@ -106,18 +131,17 @@ void DnsConfigServicePosix::Watch(const CallbackType& callback) { |
| // Even if watchers fail, we keep the other one as it provides useful signals. |
| if (config_watcher_->Watch( |
| - FilePath(kFilePathConfig), |
| - base::Bind(&DnsConfigServicePosix::OnConfigChanged, |
| - base::Unretained(this)))) { |
| + base::Bind(&DnsConfigServicePosix::OnConfigChanged, |
| + base::Unretained(this)))) { |
| OnConfigChanged(true); |
| } else { |
| OnConfigChanged(false); |
| } |
| if (hosts_watcher_->Watch( |
| - FilePath(kFilePathHosts), |
| - base::Bind(&DnsConfigServicePosix::OnHostsChanged, |
| - base::Unretained(this)))) { |
| + FilePath(kFilePathHosts), |
| + base::Bind(&DnsConfigServicePosix::OnHostsChanged, |
| + base::Unretained(this)))) { |
| OnHostsChanged(true); |
| } else { |
| OnHostsChanged(false); |