Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: net/base/network_change_notifier_win.h

Issue 9540011: [net] Add DNS-related signals and NetLog to NetworkChangeNotifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved DNS watch to a separate IO thread on mac. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_change_notifier_mac.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « net/base/network_change_notifier_mac.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698