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/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index cd7c858..e317819 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -14,7 +14,10 @@
 #include <glib.h>
 
 #include "update_engine/certificate_checker.h"
+#include "update_engine/connection_manager.h"
 #include "update_engine/http_fetcher.h"
+#include "update_engine/system_state.h"
+
 
 // This is a concrete implementation of HttpFetcher that uses libcurl to do the
 // http work.
@@ -27,10 +30,9 @@
   static const int kMaxRetryCountOobeComplete;
   static const int kMaxRetryCountOobeNotComplete;
 
-  explicit LibcurlHttpFetcher(ProxyResolver* proxy_resolver,
-                              SystemState* system_state)
-      : HttpFetcher(proxy_resolver),
-        system_state_(system_state),
+  LibcurlHttpFetcher(ProxyResolver* proxy_resolver,
+                     SystemState* system_state)
+      : HttpFetcher(proxy_resolver, system_state),
         curl_multi_handle_(NULL),
         curl_handle_(NULL),
         curl_http_headers_(NULL),
@@ -46,8 +48,6 @@
         no_network_retry_count_(0),
         no_network_max_retries_(0),
         idle_seconds_(1),
-        force_connection_type_(false),
-        forced_expensive_connection_(false),
         force_build_type_(false),
         forced_official_build_(false),
         in_write_callback_(false),
@@ -94,11 +94,6 @@
     no_network_max_retries_ = retries;
   }
 
-  void SetConnectionAsExpensive(bool is_expensive) {
-    force_connection_type_ = true;
-    forced_expensive_connection_ = is_expensive;
-  }
-
   void SetBuildType(bool is_official) {
     force_build_type_ = true;
     forced_official_build_ = is_official;
@@ -117,7 +112,7 @@
   // Callback for when proxy resolution has completed. This begins the
   // transfer.
   void ProxiesResolved();
-   
+
   // Asks libcurl for the http response code and stores it in the object.
   void GetHttpResponseCode();
 
@@ -187,16 +182,13 @@
   // be destroyed.
   void ForceTransferTermination();
 
-  // Returns whether or not the current network connection is considered
-  // expensive.
-  bool ConnectionIsExpensive() const;
+  // Returns true if updates are allowed over the current type of connection.
+  // False otherwise.
+  bool IsUpdateAllowedOverCurrentConnection() const;
 
   // Returns whether or not the current build is official.
   bool IsOfficialBuild() const;
 
-  // External state of the system
-  SystemState* system_state_;
-
   // Handles for the libcurl library
   CURLM *curl_multi_handle_;
   CURL *curl_handle_;
@@ -245,11 +237,6 @@
   // Seconds to wait before asking libcurl to "perform".
   int idle_seconds_;
 
-  // If true, assume the network is expensive or not, according to
-  // forced_expensive_connection_. (Useful for testing).
-  bool force_connection_type_;
-  bool forced_expensive_connection_;
-
   // If true, assume the build is official or not, according to
   // forced_official_build_. Useful for testing.
   bool force_build_type_;