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/chrome_proxy_resolver_unittest.cc b/chrome_proxy_resolver_unittest.cc
index 66b2401..1cdd5bf 100644
--- a/chrome_proxy_resolver_unittest.cc
+++ b/chrome_proxy_resolver_unittest.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <deque>
#include <string>
-#include <vector>
#include <gtest/gtest.h>
#include "update_engine/chrome_proxy_resolver.h"
#include "update_engine/mock_dbus_interface.h"
+using std::deque;
using std::string;
-using std::vector;
using ::testing::_;
using ::testing::Return;
using ::testing::SetArgumentPointee;
@@ -38,7 +38,7 @@
"\"mode\":4}";
ChromeProxyResolver resolver(NULL);
- vector<string> out;
+ deque<string> out;
string urls[] = {"http://foo.com/update", "https://bar.com/foo.gz"};
string multi_settings[] = {kAll, kHttpHttps};
for (size_t i = 0; i < arraysize(urls); i++) {
@@ -119,7 +119,7 @@
SetArgumentPointee<9>(ret_array),
Return(TRUE)));
- vector<string> proxies;
+ deque<string> proxies;
EXPECT_TRUE(resolver.GetProxiesForUrl("http://user:pass@foo.com:22",
&proxies));
EXPECT_EQ(2, proxies.size());