summaryrefslogtreecommitdiffstats
path: root/net/base/network_change_notifier_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/network_change_notifier_win.cc')
-rw-r--r--net/base/network_change_notifier_win.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc
index eccacaa..928a688 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() {