AU: Manual proxy support
Utilize the ChromeProxyResolver to resolve proxies in our network
requests. This means the following changes:
- HttpFetcher classes take a ProxyResolver* in their ctor. Also, a few
useful functions in HttpFetcher to allow subclasses to iterate
through the proxies.
- LibcurlHttpFetcher support for using the ProxyResolver. It will
attempt to use each proxy in the order specified. If any data comes
in from any proxy, it won't continue down the list and will continue
to use that proxy for its lifetime.
- UpdateAttempter can choose, for a given update session, whether or
not to use the ChromeProxyResolver or DirectProxyResolver. For now,
the logic is: for automatic checks, 80% of the time use
ChromeProxyResolver, 20% DirectProxyResolver. For manual checks, the
first 19 manual checks in a row use Chrome, then once it uses
Direct, then starts over again. The idea is that the updater doesn't
necessarily trust Chrome, so some requests should skip it. If a
manual check is performed, the user likely wants her proxy settings
honored, so use them, but don't allow frequent manual checks to
starve out usage of the DirectProxyResolver.
- Updates to tests
BUG=3167
TEST=unittests, tested on device
Review URL: http://codereview.chromium.org/5205002
Change-Id: Iee0f589e5b28d4b804afe1f5b6729ba066d48d62
diff --git a/proxy_resolver.h b/proxy_resolver.h
index 5d9064c..af228d2 100644
--- a/proxy_resolver.h
+++ b/proxy_resolver.h
@@ -7,8 +7,8 @@
#include <base/logging.h>
+#include <deque>
#include <string>
-#include <vector>
namespace chromeos_update_engine {
@@ -26,7 +26,7 @@
// 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;
+ std::deque<std::string>* out_proxies) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ProxyResolver);
@@ -35,8 +35,9 @@
// Always says to not use a proxy
class DirectProxyResolver : public ProxyResolver {
public:
+ DirectProxyResolver() {}
virtual bool GetProxiesForUrl(const std::string& url,
- std::vector<std::string>* out_proxies);
+ std::deque<std::string>* out_proxies);
private:
DISALLOW_COPY_AND_ASSIGN(DirectProxyResolver);