зеркало из https://github.com/mozilla/gecko-dev.git
Bug 966244 - Alarms are not updated after clearStats. r=gene, r=jshih
This commit is contained in:
Родитель
fd4975a3c5
Коммит
ae10708769
|
@ -576,7 +576,7 @@ NetworkStatsDB.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearInterfaceStats: function clearInterfaceStats(aNetwork, aResultCb) {
|
clearInterfaceStats: function clearInterfaceStats(aNetwork, aResultCb) {
|
||||||
let network = [aNetwork.id, aNetwork.type];
|
let network = [aNetwork.network.id, aNetwork.network.type];
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
// Clear and save an empty sample to keep sync with system counters
|
// Clear and save an empty sample to keep sync with system counters
|
||||||
|
@ -609,7 +609,7 @@ NetworkStatsDB.prototype = {
|
||||||
self._saveStats(aTxn, aStore, sample);
|
self._saveStats(aTxn, aStore, sample);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, aResultCb);
|
}, this._resetAlarms.bind(this, aNetwork.networkId, aResultCb));
|
||||||
},
|
},
|
||||||
|
|
||||||
clearStats: function clearStats(aNetworks, aResultCb) {
|
clearStats: function clearStats(aNetworks, aResultCb) {
|
||||||
|
@ -863,6 +863,7 @@ NetworkStatsDB.prototype = {
|
||||||
let record = { networkId: aAlarm.networkId,
|
let record = { networkId: aAlarm.networkId,
|
||||||
absoluteThreshold: aAlarm.absoluteThreshold,
|
absoluteThreshold: aAlarm.absoluteThreshold,
|
||||||
relativeThreshold: aAlarm.relativeThreshold,
|
relativeThreshold: aAlarm.relativeThreshold,
|
||||||
|
startTime: aAlarm.startTime,
|
||||||
data: aAlarm.data,
|
data: aAlarm.data,
|
||||||
manifestURL: aAlarm.manifestURL,
|
manifestURL: aAlarm.manifestURL,
|
||||||
pageURL: aAlarm.pageURL };
|
pageURL: aAlarm.pageURL };
|
||||||
|
@ -878,6 +879,7 @@ NetworkStatsDB.prototype = {
|
||||||
let alarm = { networkId: aRecord.networkId,
|
let alarm = { networkId: aRecord.networkId,
|
||||||
absoluteThreshold: aRecord.absoluteThreshold,
|
absoluteThreshold: aRecord.absoluteThreshold,
|
||||||
relativeThreshold: aRecord.relativeThreshold,
|
relativeThreshold: aRecord.relativeThreshold,
|
||||||
|
startTime: aRecord.startTime,
|
||||||
data: aRecord.data,
|
data: aRecord.data,
|
||||||
manifestURL: aRecord.manifestURL,
|
manifestURL: aRecord.manifestURL,
|
||||||
pageURL: aRecord.pageURL };
|
pageURL: aRecord.pageURL };
|
||||||
|
@ -1004,5 +1006,29 @@ NetworkStatsDB.prototype = {
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
}
|
||||||
}, aResultCb);
|
}, aResultCb);
|
||||||
|
},
|
||||||
|
|
||||||
|
_resetAlarms: function _resetAlarms(aNetworkId, aResultCb) {
|
||||||
|
this.dbNewTxn(ALARMS_STORE_NAME, "readwrite", function(txn, store) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Reset alarms for network " + aNetworkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
let lowerFilter = [aNetworkId, 0];
|
||||||
|
let upperFilter = [aNetworkId, ""];
|
||||||
|
let range = IDBKeyRange.bound(lowerFilter, upperFilter);
|
||||||
|
|
||||||
|
store.index("alarm").openCursor(range).onsuccess = function onsuccess(event) {
|
||||||
|
let cursor = event.target.result;
|
||||||
|
if (cursor) {
|
||||||
|
if (cursor.value.startTime) {
|
||||||
|
cursor.value.relativeThreshold = cursor.value.threshold;
|
||||||
|
cursor.update(cursor.value);
|
||||||
|
}
|
||||||
|
cursor.continue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, aResultCb);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -465,7 +465,9 @@ this.NetworkStatsService = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network = {network: network, networkId: aNetId};
|
||||||
self._db.clearInterfaceStats(network, function onDBCleared(aError, aResult) {
|
self._db.clearInterfaceStats(network, function onDBCleared(aError, aResult) {
|
||||||
|
self._updateCurrentAlarm(aNetId);
|
||||||
mm.sendAsyncMessage("NetworkStats:Clear:Return",
|
mm.sendAsyncMessage("NetworkStats:Clear:Return",
|
||||||
{ id: msg.id, error: aError, result: aResult });
|
{ id: msg.id, error: aError, result: aResult });
|
||||||
});
|
});
|
||||||
|
@ -482,7 +484,14 @@ this.NetworkStatsService = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let networks = aResult;
|
let networks = aResult;
|
||||||
|
networks.forEach(function(network, index) {
|
||||||
|
networks[index] = {network: network, networkId: self.getNetworkId(network.id, network.type)};
|
||||||
|
}, self);
|
||||||
|
|
||||||
self._db.clearStats(networks, function onDBCleared(aError, aResult) {
|
self._db.clearStats(networks, function onDBCleared(aError, aResult) {
|
||||||
|
networks.forEach(function(network, index) {
|
||||||
|
self._updateCurrentAlarm(network.networkId);
|
||||||
|
}, self);
|
||||||
mm.sendAsyncMessage("NetworkStats:ClearAll:Return",
|
mm.sendAsyncMessage("NetworkStats:ClearAll:Return",
|
||||||
{ id: msg.id, error: aError, result: aResult });
|
{ id: msg.id, error: aError, result: aResult });
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче