Commit 2d7fccfc authored by Tristan Cavelier's avatar Tristan Cavelier

useless methods removed

parent 5a302480
......@@ -123,164 +123,6 @@
});
};
// XXX doc string
IndexedDBStorage.prototype.getMetadata = function (id) {
var onCancel, open_req = indexedDB.open(this._database_name);
return new Promise(function (resolve, reject) {
open_req.onerror = function () {
if (open_req.result) { open_req.result.close(); }
reject(open_req.error);
};
open_req.onsuccess = function () {
// *Called at t + 1*
var tx, store, get_req, err, res, db = open_req.result;
try {
db.onerror = function () {
db.close();
};
tx = db.transaction("metadata", "readonly");
// `db.transaction` can throw an error
tx.onerror = function () {
reject(err || tx.error);
db.close();
};
tx.oncomplete = function () {
// *Called at t + 3*
if (err) {
reject(err);
} else {
resolve(res);
}
db.close();
};
// we can cancel the transaction from here
onCancel = function () {
tx.abort();
db.close();
};
store = tx.objectStore("metadata");
get_req = store.get(id);
get_req.onabort = function () {
// if cancelled, the get_req should fail
// and I hope the tx.onerror is called
err = get_req.error;
};
get_req.onerror = get_req.onabort;
get_req.onsuccess = function () {
// *Called at t + 2*
// if cancelled, this listener should not be called
if (!get_req.result) {
err = "not_found";
return;
}
res = get_req.result;
};
} catch (e) {
reject(e);
db.close();
}
};
}, function () {
if (typeof onCancel === "function") {
onCancel();
}
});
};
// XXX doc string
IndexedDBStorage.prototype.putMetadata = function (metadata) {
var onCancel, open_req = indexedDB.open(this._database_name);
return new Promise(function (resolve, reject) {
open_req.onerror = function () {
if (open_req.result) { open_req.result.close(); }
reject(open_req.error);
};
open_req.onsuccess = function () {
// *Called at t + 1*
var tx, store, db = open_req.result;
try {
tx = db.transaction("metadata", "readwrite");
tx.onerror = function () {
reject(tx.error);
db.close();
};
tx.oncomplete = function () {
// *Called at t + 3*
resolve();
db.close();
};
// we can cancel the transaction from here
onCancel = function () {
tx.abort();
db.close();
};
store = tx.objectStore("metadata");
store.put(metadata);
// store.onsuccess = function () {
// // *Called at t + 2*
// };
} catch (e) {
reject(e);
db.close();
}
};
}, function () {
if (typeof onCancel === "function") {
onCancel();
}
});
};
// XXX doc string
IndexedDBStorage.prototype.removeMetadata = function (id) {
var onCancel, open_req = indexedDB.open(this._database_name);
return new Promise(function (resolve, reject) {
open_req.onerror = function () {
if (open_req.result) { open_req.result.close(); }
reject(open_req.error);
};
open_req.onsuccess = function () {
// *Called at t + 1*
var tx, store, db = open_req.result;
try {
tx = db.transaction("metadata", "readwrite");
tx.onerror = function () {
reject(tx.error);
db.close();
};
tx.oncomplete = function () {
// *Called at t + 3*
resolve();
db.close();
};
// we can cancel the transaction from here
onCancel = function () {
tx.abort();
db.close();
};
store = tx.objectStore("metadata");
store["delete"](id);
// store.onsuccess = function () {
// // *Called at t + 2*
// };
} catch (e) {
reject(e);
db.close();
}
};
}, function () {
if (typeof onCancel === "function") {
onCancel();
}
});
};
// XXX doc string
IndexedDBStorage.prototype.removeAttachments = function (id, attachment_ids) {
/*jslint unparam: true */
return new Promise(function (done) { done(); });
};
// XXX doc string
IndexedDBStorage.prototype.get = function (command, param) {
var shared = {"connector": this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment