blob: 34b43a7eae5402c23c26c3db351a285a863150fa [file] [log] [blame]
Paul Stewartb6063942011-08-05 10:17:29 -07001// Copyright (c) 2011 The Chromium OS 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 SHILL_RESOLVER_
6#define SHILL_RESOLVER_
7
8#include <base/file_path.h>
Paul Stewart0d2ada32011-08-09 17:01:57 -07009#include <base/lazy_instance.h>
Paul Stewartb6063942011-08-05 10:17:29 -070010#include <base/memory/ref_counted.h>
Paul Stewartb6063942011-08-05 10:17:29 -070011
12#include "shill/refptr_types.h"
13
14namespace shill {
15
16// This provides a static function for dumping the DNS information out
17// of an ipconfig into a "resolv.conf" formatted file.
18class Resolver {
19 public:
Paul Stewart0d2ada32011-08-09 17:01:57 -070020 virtual ~Resolver();
21
Paul Stewartb6063942011-08-05 10:17:29 -070022 // Since this is a singleton, use Resolver::GetInstance()->Foo()
23 static Resolver *GetInstance();
24
25 void set_path(const FilePath &path) { path_ = path; }
26
27 // Set the default domain name mservice parameters, given an ipconfig entry
28 bool SetDNS(const IPConfigRefPtr &ipconfig);
29
30 // Remove any created domain name service file
31 bool ClearDNS();
32
Paul Stewart0d2ada32011-08-09 17:01:57 -070033 protected:
Paul Stewartb6063942011-08-05 10:17:29 -070034 Resolver();
Paul Stewart0d2ada32011-08-09 17:01:57 -070035
36 private:
37 friend struct base::DefaultLazyInstanceTraits<Resolver>;
38 friend class ResolverTest;
Paul Stewartb6063942011-08-05 10:17:29 -070039
40 FilePath path_;
41
42 DISALLOW_COPY_AND_ASSIGN(Resolver);
43};
44
45} // namespace shill
46
47#endif // SHILL_RESOLVER_