AU: Proxy Resolver classes
A collection of classes (abstract ProxyResolver interface and two
concrete implementations). The abstraction is one that should suit us
moving forward: a string URL is provided and a collection of proxy
servers is returned. One implementation always returns [no
proxy]. Another returns [manual settings from chrome, if applicable,
..., no proxy].
A future concrete implementation will consult Chrome via DBus with the
URL in question, however this is delayed until Chrome exposes such an
API.
As a result of this API missing from Chrome, this CL only resolves
proxies for a URL with manually input proxy settings.
Future CLs will integrate this into the rest of the update system.
BUG=3167
TEST=unit tests, (with future CLs) working proxy support on device
Review URL: http://codereview.chromium.org/5151005
Change-Id: If9dc6d09da681bca6f6ae74c896ba946ab81cb4d
diff --git a/proxy_resolver.h b/proxy_resolver.h
new file mode 100644
index 0000000..5d9064c
--- /dev/null
+++ b/proxy_resolver.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2010 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__
+
+#include <base/logging.h>
+
+#include <string>
+#include <vector>
+
+namespace chromeos_update_engine {
+
+extern const char kNoProxy[];
+
+class ProxyResolver {
+ public:
+ ProxyResolver() {}
+ virtual ~ProxyResolver() {}
+
+ // Stores a list of proxies for a given |url| in |out_proxy|.
+ // Returns true on success. The resultant proxy will be in one of the
+ // following forms:
+ // http://<host>[:<port>] - HTTP proxy
+ // socks{4,5}://<host>[:<port>] - SOCKS4/5 proxy
+ // kNoProxy - no proxy
+ virtual bool GetProxiesForUrl(const std::string& url,
+ std::vector<std::string>* out_proxies) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProxyResolver);
+};
+
+// Always says to not use a proxy
+class DirectProxyResolver : public ProxyResolver {
+ public:
+ virtual bool GetProxiesForUrl(const std::string& url,
+ std::vector<std::string>* out_proxies);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DirectProxyResolver);
+};
+
+} // namespace chromeos_update_engine
+
+#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PROXY_RESOLVER_H__