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/update_attempter.h b/update_attempter.h
index 3a4ff49..ba0bd94 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -16,9 +16,11 @@
#include <gtest/gtest_prod.h> // for FRIEND_TEST
#include "update_engine/action_processor.h"
+#include "update_engine/chrome_proxy_resolver.h"
#include "update_engine/download_action.h"
#include "update_engine/omaha_request_params.h"
#include "update_engine/omaha_response_handler_action.h"
+#include "update_engine/proxy_resolver.h"
class MetricsLibraryInterface;
struct UpdateEngineService;
@@ -47,14 +49,19 @@
public:
static const int kMaxDeltaUpdateFailures;
- UpdateAttempter(PrefsInterface* prefs, MetricsLibraryInterface* metrics_lib);
+ UpdateAttempter(PrefsInterface* prefs,
+ MetricsLibraryInterface* metrics_lib,
+ DbusGlibInterface* dbus_iface);
virtual ~UpdateAttempter();
// Checks for update and, if a newer version is available, attempts
// to update the system. Non-empty |in_app_version| or
// |in_update_url| prevents automatic detection of the parameter.
+ // If |obey_proxies| is true, the update will likely respect Chrome's
+ // proxy setting. For security reasons, we may still not honor them.
virtual void Update(const std::string& app_version,
- const std::string& omaha_url);
+ const std::string& omaha_url,
+ bool obey_proxies);
// ActionProcessorDelegate methods:
void ProcessingDone(const ActionProcessor* processor, ActionExitCode code);
@@ -153,6 +160,12 @@
// If this was a delta update attempt that failed, count it so that a full
// update can be tried when needed.
void MarkDeltaUpdateFailure();
+
+ ProxyResolver* GetProxyResolver() {
+ return obeying_proxies_ ?
+ reinterpret_cast<ProxyResolver*>(&chrome_proxy_resolver_) :
+ reinterpret_cast<ProxyResolver*>(&direct_proxy_resolver_);
+ }
// Last status notification timestamp used for throttling. Use monotonic
// TimeTicks to ensure that notifications are sent even if the system clock is
@@ -208,6 +221,17 @@
// Device paramaters common to all Omaha requests.
OmahaRequestDeviceParams omaha_request_params_;
+ // Number of consecutive manual update checks we've had where we obeyed
+ // Chrome's proxy settings.
+ int proxy_manual_checks_;
+
+ // If true, this update cycle we are obeying proxies
+ bool obeying_proxies_;
+
+ // Our two proxy resolvers
+ DirectProxyResolver direct_proxy_resolver_;
+ ChromeProxyResolver chrome_proxy_resolver_;
+
DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
};