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

Side by Side 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: CloseResState applies to OS_LINUX only 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/dns/dns_config_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_DNS_DNS_CONFIG_SERVICE_H_
6 #define NET_DNS_DNS_CONFIG_SERVICE_H_
7 #pragma once
8
9 #include <list>
10 #include <map>
11 #include <string>
12 #include <vector>
13
14 #include "base/time.h"
15 #include "net/base/net_export.h"
16
17 namespace net {
18
19 class IPEndPoint;
20
21 // DnsConfig stores configuration of the system resolver.
22 struct NET_EXPORT_PRIVATE DnsConfig {
23 DnsConfig();
24 virtual ~DnsConfig();
25
26 bool Equals(const DnsConfig& d) const;
27
28 bool Valid() const {
29 return !nameservers.empty();
30 }
31
32 // List of name server addresses.
33 std::vector<IPEndPoint> nameservers;
34 // Suffix search list; used on first lookup when number of dots in given name
35 // is less than |ndots|.
36 std::vector<std::string> search;
37
38 // Resolver options; see man resolv.conf.
39 // TODO(szym): use |ndots| and |search| to determine the sequence of FQDNs
40 // to query given a specific name.
41
42 // Minimum number of dots before global resolution precedes |search|.
43 int ndots;
44 // Time between retransmissions, see res_state.retrans.
45 base::TimeDelta timeout;
46 // Maximum number of retries, see res_state.retry.
47 int attempts;
48 // Round robin entries in |nameservers| for subsequent requests.
49 bool rotate;
50 // Enable EDNS0 extensions.
51 bool edns0;
52 };
53
54 // Service for watching when the system DNS settings have changed.
55 // Depending on the platform, watches files in /etc/ or win registry.
56 class NET_EXPORT_PRIVATE DnsConfigService {
57 public:
58 // Callback interface for the client. The observer is called on the same
59 // thread as Watch(). Observer must outlive the service.
60 class Observer {
61 public:
62 virtual ~Observer() {}
63
64 // Called only when |dns_config| is different from the last check.
65 virtual void OnConfigChanged(const DnsConfig& dns_config) = 0;
66 };
67
68 // Creates the platform-specific DnsConfigService.
69 static DnsConfigService* CreateSystemService();
70
71 DnsConfigService() {}
72 virtual ~DnsConfigService() {}
73
74 // Immediately starts watching system configuration for changes and attempts
75 // to read the configuration. For some platform implementations, the current
76 // thread must have an IO loop (for base::files::FilePathWatcher).
77 virtual void Watch() = 0;
78
79 // If a config is available, |observer| will immediately be called with
80 // OnConfigChanged.
81 virtual void AddObserver(Observer* observer) = 0;
82 virtual void RemoveObserver(Observer* observer) = 0;
83
84 private:
85 DISALLOW_COPY_AND_ASSIGN(DnsConfigService);
86 };
87
88 } // namespace net
89
90 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_
91
OLDNEW
« no previous file with comments | « no previous file | net/dns/dns_config_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698