summaryrefslogtreecommitdiffstats
path: root/net/dns/dns_config_service_posix.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/dns/dns_config_service_posix.h')
-rw-r--r--net/dns/dns_config_service_posix.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/net/dns/dns_config_service_posix.h b/net/dns/dns_config_service_posix.h
index 349c82d..7e266ba 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);
};