AU: Don't use network on expensive connection types

Specifically:

- FlimFlam proxy class to query the current network status and find
out if it's expensive.
- Dbus Interface, so dbus can be mocked.
- Libcurl change to redirect the URL if we are on an expensive
connection. This may seem hacky, but the reason I avoided retooling
the whole class is that we may decide that some network usage is
okay on pricy connections. Perhaps it's okay to throttle. So, for
now this is a more minimal change.

BUG=chromium-os:2397
TEST=Unit tests, tested that flimflam proxy works on the device.

Review URL: http://codereview.chromium.org/4029002

Change-Id: Ic4dcde1ca863bda890bc46a55c552e2b32d9433d
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 69e794f..2628ecc 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -33,6 +33,8 @@
         retry_count_(0),
         retry_seconds_(60),
         idle_seconds_(1),
+        force_connection_type_(false),
+        forced_expensive_connection_(false),
         in_write_callback_(false),
         terminate_requested_(false) {}
 
@@ -67,6 +69,11 @@
 
   // Sets the retry timeout. Useful for testing.
   void set_retry_seconds(int seconds) { retry_seconds_ = seconds; }
+  
+  void SetConnectionAsExpensive(bool is_expensive) {
+    force_connection_type_ = true;
+    forced_expensive_connection_ = is_expensive;
+  }
 
  private:
   // Asks libcurl for the http response code and stores it in the object.
@@ -122,6 +129,10 @@
   // curl(m) handles, io_channels_, timeout_source_.
   void CleanUp();
 
+  // Returns whether or not the current network connection is considered
+  // expensive.
+  bool ConnectionIsExpensive() const;
+
   // Handles for the libcurl library
   CURLM *curl_multi_handle_;
   CURL *curl_handle_;
@@ -157,6 +168,11 @@
 
   // 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, we are currently performing a write callback on the delegate.
   bool in_write_callback_;