Paul Stewart | b606394 | 2011-08-05 10:17:29 -0700 | [diff] [blame^] | 1 | // 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> |
| 9 | #include <base/memory/ref_counted.h> |
| 10 | #include <base/memory/singleton.h> |
| 11 | |
| 12 | #include "shill/refptr_types.h" |
| 13 | |
| 14 | namespace shill { |
| 15 | |
| 16 | // This provides a static function for dumping the DNS information out |
| 17 | // of an ipconfig into a "resolv.conf" formatted file. |
| 18 | class Resolver { |
| 19 | public: |
| 20 | // Since this is a singleton, use Resolver::GetInstance()->Foo() |
| 21 | static Resolver *GetInstance(); |
| 22 | |
| 23 | void set_path(const FilePath &path) { path_ = path; } |
| 24 | |
| 25 | // Set the default domain name mservice parameters, given an ipconfig entry |
| 26 | bool SetDNS(const IPConfigRefPtr &ipconfig); |
| 27 | |
| 28 | // Remove any created domain name service file |
| 29 | bool ClearDNS(); |
| 30 | |
| 31 | private: |
| 32 | friend struct DefaultSingletonTraits<Resolver>; |
| 33 | friend class ResolverTest; |
| 34 | |
| 35 | // Don't allow this object to be created |
| 36 | Resolver(); |
| 37 | ~Resolver(); |
| 38 | |
| 39 | FilePath path_; |
| 40 | |
| 41 | DISALLOW_COPY_AND_ASSIGN(Resolver); |
| 42 | }; |
| 43 | |
| 44 | } // namespace shill |
| 45 | |
| 46 | #endif // SHILL_RESOLVER_ |