Index: net/dns/dns_config_service_posix.h |
diff --git a/net/dns/dns_config_service_posix.h b/net/dns/dns_config_service_posix.h |
index 349c82d1b8b543b4e3abfac8b25d20611e5a8378..7e266ba0460cc792f6b256dce50bb9ecdd1a07ad 100644 |
--- a/net/dns/dns_config_service_posix.h |
+++ b/net/dns/dns_config_service_posix.h |
@@ -12,25 +12,50 @@ |
#endif |
#include "base/compiler_specific.h" |
+#include "base/files/file_path.h" |
#include "net/base/net_export.h" |
+#include "net/base/network_change_notifier.h" |
#include "net/dns/dns_config_service.h" |
+namespace base { |
+class Time; |
+} // namespace base |
+ |
namespace net { |
// Use DnsConfigService::CreateSystemService to use it outside of tests. |
namespace internal { |
+// Note: On Android NetworkChangeNotifier::OnNetworkChanged() signals must be |
+// passed in via calls to OnNetworkChanged(). |
class NET_EXPORT_PRIVATE DnsConfigServicePosix : public DnsConfigService { |
public: |
DnsConfigServicePosix(); |
~DnsConfigServicePosix() override; |
+#if defined(OS_ANDROID) |
+ // Returns whether the DnsConfigServicePosix witnessed a DNS configuration |
+ // change since |since_time|. Requires that callers have started listening |
+ // for NetworkChangeNotifier::OnNetworkChanged() signals, and passing them in |
+ // via OnNetworkChanged(), prior to |since_time|. |
+ bool SeenChangeSince(const base::Time& since_time) const; |
+ // NetworkChangeNotifier::OnNetworkChanged() signals must be passed |
+ // in via calls to OnNetworkChanged(). Allowing external sources of |
+ // this signal allows users of DnsConfigServicePosix to start watching for |
+ // NetworkChangeNotifier::OnNetworkChanged() signals prior to the |
+ // DnsConfigServicePosix even being created. |
+ void OnNetworkChanged(NetworkChangeNotifier::ConnectionType type); |
+#endif |
+ |
+ void SetDnsConfigForTesting(const DnsConfig* dns_config); |
+ |
protected: |
// DnsConfigService: |
void ReadNow() override; |
bool StartWatching() override; |
private: |
+ friend class DnsConfigServicePosixTest; |
class Watcher; |
class ConfigReader; |
class HostsReader; |
@@ -39,8 +64,16 @@ class NET_EXPORT_PRIVATE DnsConfigServicePosix : public DnsConfigService { |
void OnHostsChanged(bool succeeded); |
scoped_ptr<Watcher> watcher_; |
+ // Allow a mock hosts file for testing purposes. |
+ const base::FilePath::CharType* file_path_hosts_; |
+ // Allow a mock DNS server for testing purposes. |
+ const DnsConfig* dns_config_for_testing_; |
scoped_refptr<ConfigReader> config_reader_; |
scoped_refptr<HostsReader> hosts_reader_; |
+#if defined(OS_ANDROID) |
+ // Has DnsConfigWatcher detected any config chagnes yet? |
+ bool seen_config_change_; |
+#endif |
DISALLOW_COPY_AND_ASSIGN(DnsConfigServicePosix); |
}; |