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

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: Addressing lint errors. 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_posix.h » ('j') | net/dns/dns_config_service_posix.h » ('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_CONFIG_SERVICE_H_
cbentzel 2011/08/15 18:16:34 This needs to be NET_DNS_DNS_CONFIG_SERVICE_H fo
szym 2011/08/15 22:02:01 Done.
6 #define NET_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_api.h"
16 #include "net/base/net_util.h"
cbentzel 2011/08/15 18:16:34 Do you need the net_util.h include?
szym 2011/08/15 22:02:01 Done.
17
18 namespace net {
19
20 class IPEndPoint;
21
22 // DnsConfig stores configuration of the system resolver.
23 struct DnsConfig {
cbentzel 2011/08/15 18:16:34 This will need to be NET_EXPORT_PRIVATE for unit t
szym 2011/08/15 22:02:01 Done.
24 // Default values are taken from glibc resolv.h.
25 DnsConfig()
26 : ndots(1),
27 timeout(base::TimeDelta::FromSeconds(5)),
28 attempts(2),
29 rotate(false),
30 edns0(false) {}
31
32 // List of name server addresses.
33 std::vector<IPEndPoint> nameservers;
34 // Suffix search list overrides |domain| and is used on first lookup when
35 // number of dots in given name 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 bool Equals(const DnsConfig& d) const {
cbentzel 2011/08/15 18:16:34 Nit: methods are ordered before variables. http:/
cbentzel 2011/08/15 18:16:34 I'm also not sure if this should be inlined, as it
szym 2011/08/15 22:02:01 Done.
54 return (nameservers == d.nameservers) &&
55 (search == d.search) &&
56 (ndots == d.ndots) &&
57 (timeout == d.timeout) &&
58 (attempts == d.attempts) &&
59 (rotate == d.rotate) &&
60 (edns0 == d.edns0);
61 }
62
63 bool Valid() const {
64 return !nameservers.empty();
65 }
66 };
67
68 // Service for watching when the system DNS settings have changed.
69 // Depending on the platform, watches files in /etc/ or win registry.
70 class DnsConfigService {
cbentzel 2011/08/15 18:16:34 This will also need to be NET_EXPORT_PRIVATE for u
szym 2011/08/15 22:02:01 Done.
71 public:
72 // Callback interface for the client. The observer is called on the same
73 // thread as Watch(). Observer must outlive the service.
74 class Observer {
75 public:
76 virtual ~Observer() {}
77
78 // Called only when |dns_config| is different from the last check.
79 virtual void OnConfigChanged(const DnsConfig& dns_config) = 0;
80 };
81
82 // Creates the platform-specific DnsConfigService.
83 static DnsConfigService* CreateSystemService();
84
85 DnsConfigService() {}
86 virtual ~DnsConfigService() {}
87
88 // Immediately starts watching system configuration for changes and attempts
89 // to read the configuration. For some platform implementations, the current
90 // thread must have an IO loop (for base::files::FilePathWatcher).
91 virtual void Watch() = 0;
92
93 // If a config is available, |observer| will immediately be called with
94 // OnConfigChanged.
95 virtual void AddObserver(Observer* observer) = 0;
96 virtual void RemoveObserver(Observer* observer) = 0;
97
98 private:
99 DISALLOW_COPY_AND_ASSIGN(DnsConfigService);
100 };
101
102 } // namespace net
103
104 #endif // NET_DNS_CONFIG_SERVICE_H_
105
OLDNEW
« no previous file with comments | « no previous file | net/dns/dns_config_service_posix.h » ('j') | net/dns/dns_config_service_posix.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698