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..e6550121aab62290d03028139b80f47285a7e682 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 |
| @@ -85,6 +89,9 @@ namespace internal { |
| DnsConfigServicePosix::DnsConfigServicePosix() |
| : config_watcher_(new FilePathWatcherWrapper()), |
| hosts_watcher_(new FilePathWatcherWrapper()) { |
| +#if defined(OS_MACOSX) |
| + notify_watcher_.reset(new NotifyWatcherMac()); |
| +#endif |
| config_reader_ = new ConfigReader( |
| base::Bind(&DnsConfigServicePosix::OnConfigRead, |
| base::Unretained(this))); |
| @@ -104,11 +111,21 @@ void DnsConfigServicePosix::Watch(const CallbackType& callback) { |
| DCHECK(!callback.is_null()); |
| set_callback(callback); |
| + base::Callback<void(bool succeeded)> config_callback = |
| + base::Bind(&DnsConfigServicePosix::OnConfigChanged, |
| + base::Unretained(this)); |
| + |
| // 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)))) { |
| +#if defined(OS_MACOSX) |
| + // TODO(szym): Use dns_configuration_notify_key() from dnsinfo.h? |
|
Mark Mentovai
2012/04/17 16:27:43
Yes. Don’t hard-code.
(Unless you have a good rea
szym
2012/04/17 19:39:31
#include <dnsinfo.h> does not work on my Mac. It s
Mark Mentovai
2012/04/17 19:47:39
szym wrote:
|
| + // TODO(szym): Remove |config_watcher_| and use |notify_watcher_| exclusively. |
|
Mark Mentovai
2012/04/17 16:27:43
…implying that both should just be different imple
szym
2012/04/17 19:39:31
That makes sense. I'm quite confident NotifyWatche
|
| + const char* kDnsNotifyKey = "com.apple.system.SystemConfiguration." |
| + "dns_configuration"; |
|
Mark Mentovai
2012/04/17 16:27:43
If you were keeping this, which you aren’t, it’d b
|
| + if (notify_watcher_->Watch(kDnsNotifyKey, config_callback) && |
| + config_watcher_->Watch(FilePath(kFilePathConfig), config_callback)) { |
| +#else |
| + if (config_watcher_->Watch(FilePath(kFilePathConfig), config_callback)) { |
| +#endif |
| OnConfigChanged(true); |
| } else { |
| OnConfigChanged(false); |