From 05aad32d741012a173ea8f1a4b5072dabe7c0188 Mon Sep 17 00:00:00 2001 From: "szym@chromium.org" Date: Wed, 16 May 2012 18:10:53 +0000 Subject: [net/dns] Isolate DnsConfigWatcher from DnsConfigService. DnsConfigWatcher is installed at NetworkChangeNotifier and provides signals to DNSObservers. DnsConfigService becomes a DNSObserver. BUG=114827,114223,128166 TEST=./net_unittests --gtest_filter=DnsConfigService* Review URL: https://chromiumcodereview.appspot.com/10377092 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137457 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/network_change_notifier_win.cc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to '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 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() { -- cgit v1.1