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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/dns/dns_config_service.cc » ('j') | net/dns/dns_config_service_posix.cc » ('J')
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
25 bool Equals(const DnsConfig& d) const;
26
27 bool Valid() const {
28 return !nameservers.empty();
29 }
30
31 // List of name server addresses.
32 std::vector<IPEndPoint> nameservers;
33 // Suffix search list; used on first lookup when number of dots in given name
34 // is less than |ndots|.
35 std::vector<std::string> search;
36
37 // Resolver options; see man resolv.conf.
38 // TODO(szym): use |ndots| and |search| to determine the sequence of FQDNs
39 // to query given a specific name.
40
41 // Minimum number of dots before global resolution precedes |search|.
42 int ndots;
43 // Time between retransmissions, see res_state.retrans.
44 base::TimeDelta timeout;
45 // Maximum number of retries, see res_state.retry.
46 int attempts;
47 // Round robin entries in |nameservers| for subsequent requests.
48 bool rotate;
49 // Enable EDNS0 extensions.
50 bool edns0;
51 };
52
53 // Service for watching when the system DNS settings have changed.
54 // Depending on the platform, watches files in /etc/ or win registry.
55 class NET_EXPORT_PRIVATE DnsConfigService {
56 public:
57 // Callback interface for the client. The observer is called on the same
58 // thread as Watch(). Observer must outlive the service.
59 class Observer {
60 public:
61 virtual ~Observer() {}
62
63 // Called only when |dns_config| is different from the last check.
64 virtual void OnConfigChanged(const DnsConfig& dns_config) = 0;
65 };
66
67 // Creates the platform-specific DnsConfigService.
68 static DnsConfigService* CreateSystemService();
69
70 DnsConfigService() {}
71 virtual ~DnsConfigService() {}
72
73 // Immediately starts watching system configuration for changes and attempts
74 // to read the configuration. For some platform implementations, the current
75 // thread must have an IO loop (for base::files::FilePathWatcher).
76 virtual void Watch() = 0;
77
78 // If a config is available, |observer| will immediately be called with
79 // OnConfigChanged.
80 virtual void AddObserver(Observer* observer) = 0;
81 virtual void RemoveObserver(Observer* observer) = 0;
82
83 private:
84 DISALLOW_COPY_AND_ASSIGN(DnsConfigService);
85 };
86
87 } // namespace net
88
89 #endif // NET_DNS_DNS_CONFIG_SERVICE_H_
90
OLDNEW
« 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