Commit 4c835354 authored by Romain Courteaud's avatar Romain Courteaud

IDB: reduce diff size

parent e11ab351
......@@ -130,8 +130,11 @@
}
}
function waitForOpenIndexedDB(db_name, version, index_keys, callback) {
var request;
function waitForOpenIndexedDB(storage, callback) {
var request,
db_name = storage._database_name,
version = storage._version,
index_keys = storage._index_keys;
function canceller() {
if ((request !== undefined) && (request.result !== undefined)) {
......@@ -293,8 +296,7 @@
return new RSVP.Queue()
.push(function () {
return waitForOpenIndexedDB(context._database_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["metadata"], "readonly",
function (tx) {
key = "_id";
......@@ -325,8 +327,7 @@
var context = this;
return new RSVP.Queue()
.push(function () {
return waitForOpenIndexedDB(context._database_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["metadata"], "readonly",
function (tx) {
return waitForIDBRequest(tx.objectStore("metadata").get(id));
......@@ -354,8 +355,7 @@
return new RSVP.Queue()
.push(function () {
return waitForOpenIndexedDB(context._database_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["metadata", "attachment"],
"readonly", function (tx) {
return RSVP.all([
......@@ -384,8 +384,7 @@
};
IndexedDBStorage.prototype.put = function (id, metadata) {
return waitForOpenIndexedDB(this._database_name, this._version,
this._index_keys, function (db) {
return waitForOpenIndexedDB(this, function (db) {
return waitForTransaction(db, ["metadata"], "readwrite",
function (tx) {
return waitForIDBRequest(tx.objectStore("metadata").put({
......@@ -397,8 +396,7 @@
};
IndexedDBStorage.prototype.remove = function (id) {
return waitForOpenIndexedDB(this._database_name, this._version,
this._index_keys, function (db) {
return waitForOpenIndexedDB(this, function (db) {
return waitForTransaction(db, ["metadata", "attachment", "blob"],
"readwrite", function (tx) {
......@@ -442,8 +440,7 @@
if (options === undefined) {
options = {};
}
var db_name = this._database_name,
start,
var start,
end,
array_buffer_list = [],
context = this;
......@@ -467,8 +464,7 @@
return new RSVP.Queue()
.push(function () {
return waitForOpenIndexedDB(db_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["blob"], "readonly",
function (tx) {
var key_path = buildKeyPath([id, name]),
......@@ -553,8 +549,7 @@
// Request the full blob
return new RSVP.Queue()
.push(function () {
return waitForOpenIndexedDB(db_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["attachment", "blob"], "readonly",
function (tx) {
var key_path = buildKeyPath([id, name]),
......@@ -626,7 +621,7 @@
};
IndexedDBStorage.prototype.putAttachment = function (id, name, blob) {
var db_name = this._database_name, context = this;
var context = this;
return new RSVP.Queue()
.push(function () {
// Split the blob first
......@@ -644,8 +639,7 @@
handled_size += UNITE;
}
return waitForOpenIndexedDB(db_name, context._version,
context._index_keys, function (db) {
return waitForOpenIndexedDB(context, function (db) {
return waitForTransaction(db, ["attachment", "blob"], "readwrite",
function (tx) {
var blob_store,
......@@ -712,8 +706,7 @@
};
IndexedDBStorage.prototype.removeAttachment = function (id, name) {
return waitForOpenIndexedDB(this._database_name, this._version,
this._index_keys, function (db) {
return waitForOpenIndexedDB(this, function (db) {
return waitForTransaction(db, ["attachment", "blob"], "readwrite",
function (tx) {
var promise_list = [],
......
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