UpdateEngine-side changes to allow updates over 3G based on device policy.

Some enterprise chromebooks have only 3G and hence they need the ability
to update over 3G if the enterprise policy allows that. This CL adds
the support in update_engine to enable that.

BUG=chromium-os:31099
TEST=Tested E2E on 3G, added unit tests and did regression testing.
CQ-DEPEND=I1a55a392f3dc0f12d917eb45dcf0456b57735514
Change-Id: I121bda35e54fa6c35e002a76db198d13b72b650e
Reviewed-on: https://gerrit.chromium.org/gerrit/25470
Commit-Ready: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/http_fetcher.h b/http_fetcher.h
index 2ca6fe2..0078a49 100644
--- a/http_fetcher.h
+++ b/http_fetcher.h
@@ -16,6 +16,7 @@
 
 #include "http_common.h"
 #include "update_engine/proxy_resolver.h"
+#include "update_engine/system_state.h"
 
 // This class is a simple wrapper around an HTTP library (libcurl). We can
 // easily mock out this interface for testing.
@@ -33,14 +34,15 @@
   // |proxy_resolver| is the resolver that will be consulted for proxy
   // settings. It may be null, in which case direct connections will
   // be used. Does not take ownership of the resolver.
-  explicit HttpFetcher(ProxyResolver* proxy_resolver)
+  HttpFetcher(ProxyResolver* proxy_resolver, SystemState* system_state)
       : post_data_set_(false),
         http_response_code_(0),
         delegate_(NULL),
         proxies_(1, kNoProxy),
         proxy_resolver_(proxy_resolver),
         no_resolver_idle_id_(0),
-        callback_(NULL) {}
+        callback_(NULL),
+        system_state_(system_state) {}
   virtual ~HttpFetcher();
 
   void set_delegate(HttpFetcherDelegate* delegate) { delegate_ = delegate; }
@@ -59,7 +61,7 @@
   // Returns true on success.
   bool ResolveProxiesForUrl(const std::string& url,
                             google::protobuf::Closure* callback);
-  
+
   void SetProxies(const std::deque<std::string>& proxies) {
     proxies_ = proxies;
   }
@@ -106,9 +108,12 @@
   ProxyResolver* proxy_resolver() const { return proxy_resolver_; }
 
   // These are used for testing:
-  virtual void SetConnectionAsExpensive(bool is_expensive) {}
   virtual void SetBuildType(bool is_official) {}
 
+  SystemState* GetSystemState() {
+    return system_state_;
+  }
+
  protected:
   // The URL we're actively fetching from
   std::string url_;
@@ -137,6 +142,9 @@
   // Callback for when we are resolving proxies
   google::protobuf::Closure* callback_;
 
+  // Global system context.
+  SystemState* system_state_;
+
  private:
   // Callback from the proxy resolver
   void ProxiesResolved(const std::deque<std::string>& proxies);
@@ -144,7 +152,7 @@
                                     void* data) {
     reinterpret_cast<HttpFetcher*>(data)->ProxiesResolved(proxies);
   }
-   
+
   DISALLOW_COPY_AND_ASSIGN(HttpFetcher);
 };