зеркало из https://github.com/mozilla/gecko-dev.git
Bug 986837 - Part 1: Port MozNetworkStatsData to WebIDL. r=bzbarsky
This commit is contained in:
Родитель
b22ff54d96
Коммит
94ed1cdba4
|
@ -2408,6 +2408,14 @@ Navigator::HasPermissionSettingsSupport(JSContext* /* unused */, JSObject* aGlob
|
|||
return CheckPermission(win, "permissions");
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasNetworkStatsSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return CheckPermission(win, "networkstats-manage");
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
Navigator::GetWindowFromGlobal(JSObject* aGlobal)
|
||||
|
|
|
@ -313,6 +313,8 @@ public:
|
|||
|
||||
static bool HasPermissionSettingsSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static bool HasNetworkStatsSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetWindow();
|
||||
|
|
|
@ -6,14 +6,6 @@
|
|||
|
||||
interface nsIDOMMozNetworkStatsInterface;
|
||||
|
||||
[scriptable, builtinclass, uuid(3b16fe17-5583-483a-b486-b64a3243221c)]
|
||||
interface nsIDOMMozNetworkStatsData : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long rxBytes; // Received bytes.
|
||||
readonly attribute unsigned long txBytes; // Sent bytes.
|
||||
readonly attribute jsval date; // Date.
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(f1996e44-1057-4d4b-8ff8-919e76c4cfa9)]
|
||||
interface nsIDOMMozNetworkStats : nsISupports
|
||||
{
|
||||
|
|
|
@ -27,9 +27,8 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
|||
"nsISyncMessageSender");
|
||||
|
||||
// NetworkStatsData
|
||||
const nsIClassInfo = Ci.nsIClassInfo;
|
||||
const NETWORKSTATSDATA_CID = Components.ID("{3b16fe17-5583-483a-b486-b64a3243221c}");
|
||||
const nsIDOMMozNetworkStatsData = Ci.nsIDOMMozNetworkStatsData;
|
||||
const nsIClassInfo = Ci.nsIClassInfo;
|
||||
const NETWORKSTATSDATA_CID = Components.ID("{3b16fe17-5583-483a-b486-b64a3243221c}");
|
||||
|
||||
function NetworkStatsData(aWindow, aData) {
|
||||
this.rxBytes = aData.rxBytes;
|
||||
|
@ -38,20 +37,9 @@ function NetworkStatsData(aWindow, aData) {
|
|||
}
|
||||
|
||||
NetworkStatsData.prototype = {
|
||||
__exposedProps__: {
|
||||
rxBytes: 'r',
|
||||
txBytes: 'r',
|
||||
date: 'r',
|
||||
},
|
||||
|
||||
classID : NETWORKSTATSDATA_CID,
|
||||
classInfo : XPCOMUtils.generateCI({classID: NETWORKSTATSDATA_CID,
|
||||
contractID:"@mozilla.org/networkstatsdata;1",
|
||||
classDescription: "NetworkStatsData",
|
||||
interfaces: [nsIDOMMozNetworkStatsData],
|
||||
flags: nsIClassInfo.DOM_OBJECT}),
|
||||
|
||||
QueryInterface : XPCOMUtils.generateQI([nsIDOMMozNetworkStatsData])
|
||||
QueryInterface : XPCOMUtils.generateQI([])
|
||||
};
|
||||
|
||||
// NetworkStatsInterface
|
||||
|
@ -100,7 +88,8 @@ function NetworkStats(aWindow, aStats) {
|
|||
|
||||
let samples = this.data = new aWindow.Array();
|
||||
for (let i = 0; i < aStats.data.length; i++) {
|
||||
samples.push(new NetworkStatsData(aWindow, aStats.data[i]));
|
||||
samples.push(aWindow.MozNetworkStatsData._create(
|
||||
aWindow, new NetworkStatsData(aWindow, aStats.data[i])));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +111,6 @@ NetworkStats.prototype = {
|
|||
flags: nsIClassInfo.DOM_OBJECT}),
|
||||
|
||||
QueryInterface : XPCOMUtils.generateQI([nsIDOMMozNetworkStats,
|
||||
nsIDOMMozNetworkStatsData,
|
||||
nsIDOMMozNetworkStatsInterface])
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
[JSImplementation="@mozilla.org/networkStatsdata;1",
|
||||
ChromeOnly,
|
||||
Pref="dom.mozNetworkStats.enabled",
|
||||
Func="Navigator::HasNetworkStatsSupport"]
|
||||
interface MozNetworkStatsData {
|
||||
readonly attribute unsigned long rxBytes; // Received bytes.
|
||||
readonly attribute unsigned long txBytes; // Sent bytes.
|
||||
readonly attribute Date date; // Date.
|
||||
};
|
|
@ -565,6 +565,7 @@ if CONFIG['MOZ_NFC']:
|
|||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
WEBIDL_FILES += [
|
||||
'MozNetworkStatsData.webidl',
|
||||
'MozSpeakerManager.webidl',
|
||||
'MozWifiConnectionInfoEvent.webidl',
|
||||
'MozWifiManager.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче