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

Unified Diff: net/base/network_change_notifier_mac.cc

Issue 10377092: [net/dns] Isolate DnsConfigWatcher from DnsConfigService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Braces. Created 8 years, 7 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
Index: net/base/network_change_notifier_mac.cc
diff --git a/net/base/network_change_notifier_mac.cc b/net/base/network_change_notifier_mac.cc
index ca314a199f9f6343b105a034bde290f5c55d3e72..0265ef1707814ba7596e1e0dbcfd4f23630aff77 100644
--- a/net/base/network_change_notifier_mac.cc
+++ b/net/base/network_change_notifier_mac.cc
@@ -5,6 +5,15 @@
#include "net/base/network_change_notifier_mac.h"
#include <netinet/in.h>
+#include <resolv.h>
+
+#include "base/basictypes.h"
+#include "base/threading/thread.h"
+#include "net/dns/dns_config_watcher.h"
+
+#ifndef _PATH_RESCONF // Normally defined in <resolv.h>
+#define _PATH_RESCONF "/etc/resolv.conf"
+#endif
namespace net {
@@ -14,13 +23,38 @@ static bool CalculateReachability(SCNetworkConnectionFlags flags) {
return reachable && !connection_required;
}
+class NetworkChangeNotifierMac::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);
+};
+
NetworkChangeNotifierMac::NetworkChangeNotifierMac()
: online_state_(UNINITIALIZED),
initial_state_cv_(&online_state_lock_),
- forwarder_(this) {
+ forwarder_(this),
+ dns_watcher_thread_(new DnsWatcherThread()) {
// Must be initialized after the rest of this object, as it may call back into
// SetInitialState().
config_watcher_.reset(new NetworkConfigWatcherMac(&forwarder_));
+ dns_watcher_thread_->StartWithOptions(
+ base::Thread::Options(MessageLoop::TYPE_IO, 0));
}
NetworkChangeNotifierMac::~NetworkChangeNotifierMac() {

Powered by Google App Engine
This is Rietveld 408576698