Index: net/base/network_change_notifier_win.cc |
diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc |
index eccacaa6538b57c7e826e1e51161f4199313ff5e..928a68825ea94f56e7702117cb0342b83a14a5e4 100644 |
--- a/net/base/network_change_notifier_win.cc |
+++ b/net/base/network_change_notifier_win.cc |
@@ -10,11 +10,15 @@ |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
+#include "base/threading/thread.h" |
#include "base/time.h" |
#include "net/base/winsock_init.h" |
+#include "net/dns/dns_config_watcher.h" |
#pragma comment(lib, "iphlpapi.lib") |
+namespace net { |
+ |
namespace { |
// Time between NotifyAddrChange retries, on failure. |
@@ -22,14 +26,39 @@ const int kWatchForAddressChangeRetryIntervalMs = 500; |
} // namespace |
-namespace net { |
+// Thread on which we can run DnsConfigWatcher, which requires AssertIOAllowed |
+// to open registry keys and to handle FilePathWatcher updates. |
+class NetworkChangeNotifierWin::DnsWatcherThread : public base::Thread { |
+ public: |
+ DnsWatcherThread() : base::Thread("NetworkChangeNotifier") {} |
+ |
+ virtual ~DnsWatcherThread() { |
+ Stop(); |
+ } |
+ |
+ virtual void Init() OVERRIDE { |
+ watcher_.Init(); |
+ } |
+ |
+ virtual void CleanUp() OVERRIDE { |
+ watcher_.CleanUp(); |
+ } |
+ |
+ private: |
+ internal::DnsConfigWatcher watcher_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DnsWatcherThread); |
+}; |
NetworkChangeNotifierWin::NetworkChangeNotifierWin() |
: is_watching_(false), |
sequential_failures_(0), |
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
+ dns_watcher_thread_(new DnsWatcherThread()) { |
memset(&addr_overlapped_, 0, sizeof addr_overlapped_); |
addr_overlapped_.hEvent = WSACreateEvent(); |
+ dns_watcher_thread_->StartWithOptions( |
+ base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
} |
NetworkChangeNotifierWin::~NetworkChangeNotifierWin() { |