[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
diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h
index f487501..477d1f71 100644
--- a/net/base/network_change_notifier.h
+++ b/net/base/network_change_notifier.h
@@ -8,12 +8,17 @@
 
 #include "base/basictypes.h"
 #include "base/observer_list_threadsafe.h"
+#include "base/synchronization/lock.h"
 #include "net/base/net_export.h"
 
 namespace net {
 
 class NetworkChangeNotifierFactory;
 
+namespace internal {
+class DnsConfigWatcher;
+}
+
 // NetworkChangeNotifier monitors the system for network changes, and notifies
 // registered observers of those events.  Observers may register on any thread,
 // and will be called back on the thread from which they registered.
@@ -27,8 +32,10 @@
     CHANGE_DNS_SETTINGS = 1 << 0,
     // The HOSTS file has changed.
     CHANGE_DNS_HOSTS = 1 << 1,
-    // Computer name has changed.
-    CHANGE_DNS_LOCALHOST = 1 << 2,
+    // The watcher has started.
+    CHANGE_DNS_WATCH_STARTED = 1 << 2,
+    // The watcher has failed and will not be available until further notice.
+    CHANGE_DNS_WATCH_FAILED = 1 << 3,
   };
 
   class NET_EXPORT IPAddressObserver {
@@ -105,6 +112,9 @@
   // will be successfully.
   static bool IsOffline();
 
+  // Returns true if DNS watcher is operational.
+  static bool IsWatchingDNS();
+
   // Like Create(), but for use in tests.  The mock object doesn't monitor any
   // events, it merely rebroadcasts notifications when requested.
   static NetworkChangeNotifier* CreateMock();
@@ -135,6 +145,8 @@
   }
 
  protected:
+  friend class internal::DnsConfigWatcher;
+
   NetworkChangeNotifier();
 
   // Broadcasts a notification to all registered observers.  Note that this
@@ -172,6 +184,13 @@
   const scoped_refptr<ObserverListThreadSafe<DNSObserver> >
       resolver_state_observer_list_;
 
+  // True iff DNS watchers are operational.
+  // Otherwise, OnDNSChanged might not be issued for future changes.
+  // TODO(szym): This is a temporary interface, consider restarting them.
+  //             http://crbug.com/116139
+  base::Lock watching_dns_lock_;
+  bool watching_dns_;
+
   DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
 };