Bug 868952 - Fix the getAll(...) function in AlarmDB to be more efficient. r=clian

This commit is contained in:
Zachary Easterbrook 2013-05-20 07:47:38 -04:00
parent 414da4c45b
commit cd7c034c2d

View File

@ -139,15 +139,13 @@ AlarmDB.prototype = {
"readonly",
ALARMSTORE_NAME,
function txnCb(aTxn, aStore) {
if (!aTxn.result)
if (!aTxn.result) {
aTxn.result = [];
}
aStore.mozGetAll().onsuccess = function setTxnResult(aEvent) {
aEvent.target.result.forEach(function addAlarm(aAlarm) {
if (!aManifestURL || aManifestURL == aAlarm.manifestURL)
aTxn.result.push(aAlarm);
});
let index = aStore.index("manifestURL");
index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
aTxn.result = aEvent.target.result;
debug("Request successful. Record count: " + aTxn.result.length);
};
},