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", "readonly",
ALARMSTORE_NAME, ALARMSTORE_NAME,
function txnCb(aTxn, aStore) { function txnCb(aTxn, aStore) {
if (!aTxn.result) if (!aTxn.result) {
aTxn.result = []; aTxn.result = [];
}
aStore.mozGetAll().onsuccess = function setTxnResult(aEvent) { let index = aStore.index("manifestURL");
aEvent.target.result.forEach(function addAlarm(aAlarm) { index.mozGetAll(aManifestURL).onsuccess = function setTxnResult(aEvent) {
if (!aManifestURL || aManifestURL == aAlarm.manifestURL) aTxn.result = aEvent.target.result;
aTxn.result.push(aAlarm);
});
debug("Request successful. Record count: " + aTxn.result.length); debug("Request successful. Record count: " + aTxn.result.length);
}; };
}, },