Backed out changeset 6701ef0c75b4 for landing with the wrong bug number. r=bzbarsky

This commit is contained in:
Ryan VanderMeulen 2014-05-05 10:29:29 -04:00
Родитель 26697c1ff2
Коммит edeab4f8ef
3 изменённых файлов: 16 добавлений и 27 удалений

Просмотреть файл

@ -43,24 +43,19 @@ NetworkStatsData.prototype = {
};
// NetworkStatsInterface
const NETWORKSTATSINTERFACE_CONTRACTID = "@mozilla.org/networkstatsinterface;1";
const NETWORKSTATSINTERFACE_CID = Components.ID("{f540615b-d803-43ff-8200-2a9d145a5645}");
function NetworkStatsInterface() {
function NetworkStatsInterface(aNetwork) {
if (DEBUG) {
debug("NetworkStatsInterface Constructor");
}
this.type = aNetwork.type;
this.id = aNetwork.id;
}
NetworkStatsInterface.prototype = {
__init: function(aNetwork) {
this.type = aNetwork.type;
this.id = aNetwork.id;
},
classID : NETWORKSTATSINTERFACE_CID,
contractID: NETWORKSTATSINTERFACE_CONTRACTID,
QueryInterface : XPCOMUtils.generateQI([])
}
@ -73,7 +68,8 @@ function NetworkStats(aWindow, aStats) {
}
this.appManifestURL = aStats.appManifestURL || 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.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) {
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.data = aAlarm.data;
}
@ -310,7 +307,8 @@ NetworkStatsManager.prototype = {
let networks = new this._window.Array();
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);
}

Просмотреть файл

@ -40,8 +40,7 @@ var steps = [
function () {
ok(true, "Calling getAllAlarms() with invalid network.");
req = navigator.mozNetworkStats
.getAllAlarms(new window.MozNetworkStatsInterface(mobile));
req = navigator.mozNetworkStats.getAllAlarms(mobile);
req.onsuccess = function () {
ok(false, "getAllAlarms() shouldn't succeed!");
@ -70,14 +69,13 @@ var steps = [
}
try {
navigator.mozNetworkStats.addAlarm(new window.MozNetworkStatsInterface(wifi));
navigator.mozNetworkStats.addAlarm(wifi);
} catch(ex) {
ok(ex.result == SpecialPowers.Cr.NS_ERROR_XPC_NOT_ENOUGH_ARGS,
"addAlarm() throws NS_ERROR_XPC_NOT_ENOUGH_ARGS exception when no threshold");
}
req = navigator.mozNetworkStats
.addAlarm(new window.MozNetworkStatsInterface(mobile), -100000);
req = navigator.mozNetworkStats.addAlarm(mobile, -100000);
req.onsuccess = function () {
ok(false, "addAlarm() shouldn't succeed with negative threshold.");
@ -91,8 +89,7 @@ var steps = [
function () {
ok(true, "Calling addAlarm()");
req = navigator.mozNetworkStats
.addAlarm(new window.MozNetworkStatsInterface(wifi), 1000000);
req = navigator.mozNetworkStats.addAlarm(wifi, 1000000);
req.onsuccess = function () {
ok(true, "Succeeded to add alarm. AlarmId: " + req.result);
@ -105,8 +102,7 @@ var steps = [
function () {
ok(true, "Calling getAllAlarms()");
req = navigator.mozNetworkStats
.getAllAlarms(new window.MozNetworkStatsInterface(wifi));
req = navigator.mozNetworkStats.getAllAlarms(wifi);
req.onsuccess = function () {
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,
* 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.
*/
[Constructor(optional NetworkInterface networkinterface),
JSImplementation="@mozilla.org/networkstatsinterface;1",
[JSImplementation="@mozilla.org/networkstatsinterface;1",
ChromeOnly,
Pref="dom.mozNetworkStats.enabled",
Func="Navigator::HasNetworkStatsSupport"]
interface MozNetworkStatsInterface {