| Index: net/base/network_change_notifier_win.h
|
| diff --git a/net/base/network_change_notifier_win.h b/net/base/network_change_notifier_win.h
|
| index aee5304ff6fe3d03506fa9827f99f55a1b16c14b..8058fbc308334859a07b7d90efd0226053e66f78 100644
|
| --- a/net/base/network_change_notifier_win.h
|
| +++ b/net/base/network_change_notifier_win.h
|
| @@ -14,6 +14,8 @@
|
| #include "base/threading/non_thread_safe.h"
|
| #include "base/timer.h"
|
| #include "base/win/object_watcher.h"
|
| +#include "base/win/registry.h"
|
| +#include "net/base/file_path_watcher_callback.h"
|
| #include "net/base/net_export.h"
|
| #include "net/base/network_change_notifier.h"
|
|
|
| @@ -41,6 +43,9 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierWin
|
| protected:
|
| virtual ~NetworkChangeNotifierWin();
|
|
|
| + // Begins listening for DNS changes.
|
| + void WatchForDNSChanges();
|
| +
|
| // For unit tests only.
|
| bool is_watching() { return is_watching_; }
|
| void set_is_watching(bool is_watching) { is_watching_ = is_watching; }
|
| @@ -49,9 +54,27 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierWin
|
| private:
|
| friend class NetworkChangeNotifierWinTest;
|
|
|
| + class RegistryWatcher : public base::win::ObjectWatcher::Delegate {
|
| + public:
|
| + explicit RegistryWatcher(NetworkChangeNotifierWin* notifier);
|
| + ~RegistryWatcher();
|
| +
|
| + bool Watch(const wchar_t* key);
|
| + void Cancel();
|
| + virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
|
| + private:
|
| + NetworkChangeNotifierWin* notifier_;
|
| + base::win::RegKey key_;
|
| + base::win::ObjectWatcher watcher_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RegistryWatcher);
|
| + };
|
| +
|
| // NetworkChangeNotifier methods:
|
| virtual bool IsCurrentlyOffline() const OVERRIDE;
|
|
|
| + virtual bool IsCurrentlyWatchingDNS() const OVERRIDE;
|
| +
|
| // ObjectWatcher::Delegate methods:
|
| // Must only be called on the thread |this| was created on.
|
| virtual void OnObjectSignaled(HANDLE object) OVERRIDE;
|
| @@ -70,6 +93,13 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierWin
|
| // created on.
|
| virtual bool WatchForAddressChangeInternal();
|
|
|
| + // Called by RegistryWatcher. |watch_successful| is true iff the watch
|
| + // continues successfully.
|
| + void OnRegistryChanged(bool watch_successful);
|
| +
|
| + // Called by FilePathWatcherCallback.
|
| + void OnDNSFileChanged(bool watch_successful);
|
| +
|
| // All member variables may only be accessed on the thread |this| was created
|
| // on.
|
|
|
| @@ -86,6 +116,14 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierWin
|
| // Number of times WatchForAddressChange has failed in a row.
|
| int sequential_failures_;
|
|
|
| + bool watching_dns_;
|
| + // One watcher per key of interest.
|
| + RegistryWatcher dns_policy_watcher_;
|
| + RegistryWatcher dns_dnscache_watcher_;
|
| + RegistryWatcher dns_tcpip_watcher_;
|
| +
|
| + FilePathWatcherCallback hosts_watcher_;
|
| +
|
| // Used for calling WatchForAddressChange again on failure.
|
| base::WeakPtrFactory<NetworkChangeNotifierWin> weak_factory_;
|
|
|
|
|