Bug 677166 - Part 5 - Use a pref for connection.metered. r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Mon, 16 Jan 2012 13:25:13 +0100
changeset 85965 4a9f98d2f07afb39cce383ece7f37b4421ec317e
parent 85964 5c6dc5015a9a43b95ea9cf055a36bcdc818af40a
child 85966 ae007b96ebf087c2b2a38c97532c5e05bbb55531
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs677166
milestone12.0a1
Bug 677166 - Part 5 - Use a pref for connection.metered. r=sicking
dom/network/interfaces/nsIDOMConnection.idl
dom/network/src/Connection.cpp
dom/network/src/Connection.h
modules/libpref/src/init/all.js
--- a/dom/network/interfaces/nsIDOMConnection.idl
+++ b/dom/network/interfaces/nsIDOMConnection.idl
@@ -34,9 +34,10 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 [scriptable, uuid(0bd0bcc8-ca92-43fa-97bd-aec8d79edb24)]
 interface nsIDOMMozConnection : nsISupports
 {
+  readonly attribute boolean metered;
 };
--- a/dom/network/src/Connection.cpp
+++ b/dom/network/src/Connection.cpp
@@ -32,28 +32,40 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "Connection.h"
 #include "nsIDOMClassInfo.h"
+#include "mozilla/Preferences.h"
 
 DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
 
 namespace mozilla {
 namespace dom {
 namespace network {
 
+const char* Connection::sMeteredPrefName     = "dom.network.metered";
+const bool  Connection::sMeteredDefaultValue = false;
+
 NS_INTERFACE_MAP_BEGIN(Connection)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozConnection)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozConnection)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(Connection)
 NS_IMPL_RELEASE(Connection)
 
+NS_IMETHODIMP
+Connection::GetMetered(bool* aMetered)
+{
+  *aMetered = Preferences::GetBool(sMeteredPrefName,
+                                   sMeteredDefaultValue);
+  return NS_OK;
+}
+
 } // namespace network
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/network/src/Connection.h
+++ b/dom/network/src/Connection.h
@@ -44,15 +44,19 @@ namespace mozilla {
 namespace dom {
 namespace network {
 
 class Connection : public nsIDOMMozConnection
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMMOZCONNECTION
+
+private:
+  static const char* sMeteredPrefName;
+  static const bool  sMeteredDefaultValue;
 };
 
 } // namespace network
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_network_Connection_h
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3411,16 +3411,17 @@ pref("browser.dom.window.dump.enabled", 
 
 // SPS Profiler
 pref("profiler.enabled", false);
 pref("profiler.interval", 10);
 pref("profiler.entries", 100000);
 
 // Network API
 pref("dom.network.enabled", true);
+pref("dom.network.metered", false);
 #ifdef XP_WIN
 // On 32-bit Windows, fire a low-memory notification if we have less than this
 // many mb of virtual address space available.
 pref("memory.low_virtual_memory_threshold_mb", 128);
 
 // On Windows 32- or 64-bit, fire a low-memory notification if we have less
 // than this many mb of physical memory available on the whole machine.
 pref("memory.low_physical_memory_threshold_mb", 0);