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/flimflam_proxy.h b/flimflam_proxy.h
new file mode 100644
index 0000000..d5e5ff7
--- /dev/null
+++ b/flimflam_proxy.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_FLIMFLAM_PROXY_H__
+#define CHROMEOS_PLATFORM_UPDATE_ENGINE_FLIMFLAM_PROXY_H__
+
+// This class interfaces with FlimFlam to find out data about connectivity.
+
+#include <base/basictypes.h>
+
+#include "update_engine/dbus_interface.h"
+
+namespace chromeos_update_engine {
+
+extern const char* kFlimFlamDbusService;
+extern const char* kFlimFlamDbusManagerInterface;
+extern const char* kFlimFlamDbusManagerPath;
+extern const char* kFlimFlamDbusServiceInterface;
+
+extern const char* kFlimFlamNetTypeEthernet;
+extern const char* kFlimFlamNetTypeWifi;
+extern const char* kFlimFlamNetTypeWimax;
+extern const char* kFlimFlamNetTypeBluetooth;
+extern const char* kFlimFlamNetTypeCellular;
+
+enum NetworkConnectionType {
+  kNetEthernet = 0,
+  kNetWifi,
+  kNetWimax,
+  kNetBluetooth,
+  kNetCellular,
+  kNetUnknown
+};
+
+class FlimFlamProxy {
+ public:
+  static bool GetConnectionType(DbusGlibInterface* dbus_iface,
+                                NetworkConnectionType* out_type);
+
+  static bool IsExpensiveConnectionType(NetworkConnectionType type) {
+    return type == kNetWimax || type == kNetBluetooth || type == kNetCellular;
+  }
+  static const char* StringForConnectionType(NetworkConnectionType type);
+  
+ private:
+  // Should never be allocated
+  DISALLOW_IMPLICIT_CONSTRUCTORS(FlimFlamProxy);
+};
+
+}  // namespace chromeos_update_engine
+
+#endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_FLIMFLAM_PROXY_H__