зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 6701ef0c75b4 for landing with the wrong bug number. r=bzbarsky
This commit is contained in:
Родитель
26697c1ff2
Коммит
edeab4f8ef
|
@ -43,24 +43,19 @@ NetworkStatsData.prototype = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// NetworkStatsInterface
|
// NetworkStatsInterface
|
||||||
const NETWORKSTATSINTERFACE_CONTRACTID = "@mozilla.org/networkstatsinterface;1";
|
|
||||||
const NETWORKSTATSINTERFACE_CID = Components.ID("{f540615b-d803-43ff-8200-2a9d145a5645}");
|
const NETWORKSTATSINTERFACE_CID = Components.ID("{f540615b-d803-43ff-8200-2a9d145a5645}");
|
||||||
|
|
||||||
function NetworkStatsInterface() {
|
function NetworkStatsInterface(aNetwork) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
debug("NetworkStatsInterface Constructor");
|
debug("NetworkStatsInterface Constructor");
|
||||||
}
|
}
|
||||||
|
this.type = aNetwork.type;
|
||||||
|
this.id = aNetwork.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkStatsInterface.prototype = {
|
NetworkStatsInterface.prototype = {
|
||||||
__init: function(aNetwork) {
|
|
||||||
this.type = aNetwork.type;
|
|
||||||
this.id = aNetwork.id;
|
|
||||||
},
|
|
||||||
|
|
||||||
classID : NETWORKSTATSINTERFACE_CID,
|
classID : NETWORKSTATSINTERFACE_CID,
|
||||||
|
|
||||||
contractID: NETWORKSTATSINTERFACE_CONTRACTID,
|
|
||||||
QueryInterface : XPCOMUtils.generateQI([])
|
QueryInterface : XPCOMUtils.generateQI([])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +68,8 @@ function NetworkStats(aWindow, aStats) {
|
||||||
}
|
}
|
||||||
this.appManifestURL = aStats.appManifestURL || null;
|
this.appManifestURL = aStats.appManifestURL || null;
|
||||||
this.serviceType = aStats.serviceType || null;
|
this.serviceType = aStats.serviceType || null;
|
||||||
this.network = new aWindow.MozNetworkStatsInterface(aStats.network);
|
this.network = aWindow.MozNetworkStatsInterface._create(
|
||||||
|
aWindow, new NetworkStatsInterface(aStats.network));
|
||||||
this.start = aStats.start ? new aWindow.Date(aStats.start.getTime()) : null;
|
this.start = aStats.start ? new aWindow.Date(aStats.start.getTime()) : null;
|
||||||
this.end = aStats.end ? new aWindow.Date(aStats.end.getTime()) : null;
|
this.end = aStats.end ? new aWindow.Date(aStats.end.getTime()) : null;
|
||||||
|
|
||||||
|
@ -95,7 +91,8 @@ const NETWORKSTATSALARM_CID = Components.ID("{a93ea13e-409c-4189-9b1e-95fff220be
|
||||||
|
|
||||||
function NetworkStatsAlarm(aWindow, aAlarm) {
|
function NetworkStatsAlarm(aWindow, aAlarm) {
|
||||||
this.alarmId = aAlarm.id;
|
this.alarmId = aAlarm.id;
|
||||||
this.network = new aWindow.MozNetworkStatsInterface(aAlarm.network);
|
this.network = aWindow.MozNetworkStatsInterface._create(
|
||||||
|
aWindow, new NetworkStatsInterface(aAlarm.network));
|
||||||
this.threshold = aAlarm.threshold;
|
this.threshold = aAlarm.threshold;
|
||||||
this.data = aAlarm.data;
|
this.data = aAlarm.data;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +307,8 @@ NetworkStatsManager.prototype = {
|
||||||
|
|
||||||
let networks = new this._window.Array();
|
let networks = new this._window.Array();
|
||||||
for (let i = 0; i < msg.result.length; i++) {
|
for (let i = 0; i < msg.result.length; i++) {
|
||||||
let network = new this._window.MozNetworkStatsInterface(msg.result[i]);
|
let network = this._window.MozNetworkStatsInterface._create(
|
||||||
|
this._window, new NetworkStatsInterface(msg.result[i]));
|
||||||
networks.push(network);
|
networks.push(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ var steps = [
|
||||||
function () {
|
function () {
|
||||||
ok(true, "Calling getAllAlarms() with invalid network.");
|
ok(true, "Calling getAllAlarms() with invalid network.");
|
||||||
|
|
||||||
req = navigator.mozNetworkStats
|
req = navigator.mozNetworkStats.getAllAlarms(mobile);
|
||||||
.getAllAlarms(new window.MozNetworkStatsInterface(mobile));
|
|
||||||
|
|
||||||
req.onsuccess = function () {
|
req.onsuccess = function () {
|
||||||
ok(false, "getAllAlarms() shouldn't succeed!");
|
ok(false, "getAllAlarms() shouldn't succeed!");
|
||||||
|
@ -70,14 +69,13 @@ var steps = [
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
navigator.mozNetworkStats.addAlarm(new window.MozNetworkStatsInterface(wifi));
|
navigator.mozNetworkStats.addAlarm(wifi);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
ok(ex.result == SpecialPowers.Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
|
ok(ex.result == SpecialPowers.Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
|
||||||
"addAlarm() throws NS_ERROR_XPC_NOT_ENOUGH_ARGS exception when no threshold");
|
"addAlarm() throws NS_ERROR_XPC_NOT_ENOUGH_ARGS exception when no threshold");
|
||||||
}
|
}
|
||||||
|
|
||||||
req = navigator.mozNetworkStats
|
req = navigator.mozNetworkStats.addAlarm(mobile, -100000);
|
||||||
.addAlarm(new window.MozNetworkStatsInterface(mobile), -100000);
|
|
||||||
|
|
||||||
req.onsuccess = function () {
|
req.onsuccess = function () {
|
||||||
ok(false, "addAlarm() shouldn't succeed with negative threshold.");
|
ok(false, "addAlarm() shouldn't succeed with negative threshold.");
|
||||||
|
@ -91,8 +89,7 @@ var steps = [
|
||||||
function () {
|
function () {
|
||||||
ok(true, "Calling addAlarm()");
|
ok(true, "Calling addAlarm()");
|
||||||
|
|
||||||
req = navigator.mozNetworkStats
|
req = navigator.mozNetworkStats.addAlarm(wifi, 1000000);
|
||||||
.addAlarm(new window.MozNetworkStatsInterface(wifi), 1000000);
|
|
||||||
|
|
||||||
req.onsuccess = function () {
|
req.onsuccess = function () {
|
||||||
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
|
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
|
||||||
|
@ -105,8 +102,7 @@ var steps = [
|
||||||
function () {
|
function () {
|
||||||
ok(true, "Calling getAllAlarms()");
|
ok(true, "Calling getAllAlarms()");
|
||||||
|
|
||||||
req = navigator.mozNetworkStats
|
req = navigator.mozNetworkStats.getAllAlarms(wifi);
|
||||||
.getAllAlarms(new window.MozNetworkStatsInterface(wifi));
|
|
||||||
|
|
||||||
req.onsuccess = function () {
|
req.onsuccess = function () {
|
||||||
ok(req.result.length == 1, "Only one alarm");
|
ok(req.result.length == 1, "Only one alarm");
|
||||||
|
|
|
@ -2,16 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
dictionary NetworkInterface {
|
|
||||||
long type;
|
|
||||||
DOMString id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a data interface for which the manager is recording statistics.
|
* Represents a data interface for which the manager is recording statistics.
|
||||||
*/
|
*/
|
||||||
[Constructor(optional NetworkInterface networkinterface),
|
[JSImplementation="@mozilla.org/networkstatsinterface;1",
|
||||||
JSImplementation="@mozilla.org/networkstatsinterface;1",
|
ChromeOnly,
|
||||||
Pref="dom.mozNetworkStats.enabled",
|
Pref="dom.mozNetworkStats.enabled",
|
||||||
Func="Navigator::HasNetworkStatsSupport"]
|
Func="Navigator::HasNetworkStatsSupport"]
|
||||||
interface MozNetworkStatsInterface {
|
interface MozNetworkStatsInterface {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче