summaryrefslogtreecommitdiffstats
path: root/net/base/network_change_notifier_win.cc
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 18:10:53 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 18:10:53 +0000
commit05aad32d741012a173ea8f1a4b5072dabe7c0188 (patch)
treef9b8535284f0503ef96bac3a451f995b5fcd508f /net/base/network_change_notifier_win.cc
parent1a92b28469774982203a8c88be0bb49d8275cf68 (diff)
downloadchromium_src-05aad32d741012a173ea8f1a4b5072dabe7c0188.zip
chromium_src-05aad32d741012a173ea8f1a4b5072dabe7c0188.tar.gz
chromium_src-05aad32d741012a173ea8f1a4b5072dabe7c0188.tar.bz2
[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
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() {