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

Unified Diff: net/dns/dns_config_service.h

Issue 7518028: DnsConfigService and a posix implementation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Deflaked test. Addressed memory leaks and comments. Created 9 years, 4 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
« no previous file with comments | « no previous file | net/dns/dns_config_service.cc » ('j') | net/dns/dns_config_service_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_config_service.h
diff --git a/net/dns/dns_config_service.h b/net/dns/dns_config_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..4956a0f9a370c2bfcabe274e391c90ce9555ea47
--- /dev/null
+++ b/net/dns/dns_config_service.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_DNS_DNS_CONFIG_SERVICE_H_
+#define NET_DNS_DNS_CONFIG_SERVICE_H_
+#pragma once
+
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "base/time.h"
+#include "net/base/net_export.h"
+
+namespace net {
+
+class IPEndPoint;
+
+// DnsConfig stores configuration of the system resolver.
+struct NET_EXPORT_PRIVATE DnsConfig {
+ DnsConfig();
+
+ bool Equals(const DnsConfig& d) const;
+
+ bool Valid() const {
+ return !nameservers.empty();
+ }
+
+ // List of name server addresses.
+ std::vector<IPEndPoint> nameservers;
+ // Suffix search list; used on first lookup when number of dots in given name
+ // is less than |ndots|.
+ std::vector<std::string> search;
+
+ // Resolver options; see man resolv.conf.
+ // TODO(szym): use |ndots| and |search| to determine the sequence of FQDNs
+ // to query given a specific name.
+
+ // Minimum number of dots before global resolution precedes |search|.
+ int ndots;
+ // Time between retransmissions, see res_state.retrans.
+ base::TimeDelta timeout;
+ // Maximum number of retries, see res_state.retry.
+ int attempts;
+ // Round robin entries in |nameservers| for subsequent requests.
+ bool rotate;
+ // Enable EDNS0 extensions.
+ bool edns0;
+};
+
+// Service for watching when the system DNS settings have changed.
+// Depending on the platform, watches files in /etc/ or win registry.
+class NET_EXPORT_PRIVATE DnsConfigService {
+ public:
+ // Callback interface for the client. The observer is called on the same
+ // thread as Watch(). Observer must outlive the service.
+ class Observer {
+ public:
+ virtual ~Observer() {}
+
+ // Called only when |dns_config| is different from the last check.
+ virtual void OnConfigChanged(const DnsConfig& dns_config) = 0;
+ };
+
+ // Creates the platform-specific DnsConfigService.
+ static DnsConfigService* CreateSystemService();
+
+ DnsConfigService() {}
+ virtual ~DnsConfigService() {}
+
+ // Immediately starts watching system configuration for changes and attempts
+ // to read the configuration. For some platform implementations, the current
+ // thread must have an IO loop (for base::files::FilePathWatcher).
+ virtual void Watch() = 0;
+
+ // If a config is available, |observer| will immediately be called with
+ // OnConfigChanged.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DnsConfigService);
+};
+
+} // namespace net
+
+#endif // NET_DNS_DNS_CONFIG_SERVICE_H_
+
« no previous file with comments | « no previous file | net/dns/dns_config_service.cc » ('j') | net/dns/dns_config_service_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698