shill: Add singleton to output resolver files

Output a file that can be linked to "resolv.conf" from the contents
of an ipconfig file.

BUG=chromium-os:17278
TEST=New unittest

Change-Id: Ic537dda6f1cb337d631bc75a3aaa835312ce8c01
Reviewed-on: http://gerrit.chromium.org/gerrit/5399
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/resolver.h b/resolver.h
new file mode 100644
index 0000000..bbf188f
--- /dev/null
+++ b/resolver.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_RESOLVER_
+#define SHILL_RESOLVER_
+
+#include <base/file_path.h>
+#include <base/memory/ref_counted.h>
+#include <base/memory/singleton.h>
+
+#include "shill/refptr_types.h"
+
+namespace shill {
+
+// This provides a static function for dumping the DNS information out
+// of an ipconfig into a "resolv.conf" formatted file.
+class Resolver {
+ public:
+  // Since this is a singleton, use Resolver::GetInstance()->Foo()
+  static Resolver *GetInstance();
+
+  void set_path(const FilePath &path) { path_ = path; }
+
+  // Set the default domain name mservice parameters, given an ipconfig entry
+  bool SetDNS(const IPConfigRefPtr &ipconfig);
+
+  // Remove any created domain name service file
+  bool ClearDNS();
+
+ private:
+  friend struct DefaultSingletonTraits<Resolver>;
+  friend class ResolverTest;
+
+  // Don't allow this object to be created
+  Resolver();
+  ~Resolver();
+
+  FilePath path_;
+
+  DISALLOW_COPY_AND_ASSIGN(Resolver);
+};
+
+}  // namespace shill
+
+#endif  // SHILL_RESOLVER_