Bug 677166 - Part 5 - Use a pref for connection.metered. r=sicking

This commit is contained in:
Mounir Lamouri 2012-01-16 13:25:13 +01:00
parent 5889593b3a
commit a280e39ab5
4 changed files with 18 additions and 0 deletions

View File

@ -39,4 +39,5 @@
[scriptable, uuid(0bd0bcc8-ca92-43fa-97bd-aec8d79edb24)]
interface nsIDOMMozConnection : nsISupports
{
readonly attribute boolean metered;
};

View File

@ -37,6 +37,7 @@
#include "Connection.h"
#include "nsIDOMClassInfo.h"
#include "mozilla/Preferences.h"
DOMCI_DATA(MozConnection, mozilla::dom::network::Connection)
@ -44,6 +45,9 @@ 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)
@ -53,6 +57,14 @@ 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

View File

@ -49,6 +49,10 @@ class Connection : public nsIDOMMozConnection
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMMOZCONNECTION
private:
static const char* sMeteredPrefName;
static const bool sMeteredDefaultValue;
};
} // namespace network

View File

@ -3416,6 +3416,7 @@ 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.