Bug 1435588 - (part 1) Avoid inserting records one at a time when using the sync bookmark buffer r=kitcambridge

MozReview-Commit-ID: 6xRhLrrqVok

--HG--
extra : rebase_source : 31757c405b1b16ace6103d39133cc2dfc6df11c8
This commit is contained in:
Thom Chiovoloni 2018-02-20 15:12:05 -05:00
parent f1008517f2
commit 8d161b9820

View File

@ -1076,6 +1076,9 @@ BufferedBookmarksStore.prototype = {
__proto__: BaseBookmarksStore.prototype,
_openMirrorPromise: null,
// For tests.
_batchChunkSize: 500,
ensureOpenMirror() {
if (!this._openMirrorPromise) {
this._openMirrorPromise = this._openMirror().catch(err => {
@ -1105,6 +1108,15 @@ BufferedBookmarksStore.prototype = {
});
},
async applyIncomingBatch(records) {
let buf = await this.ensureOpenMirror();
for (let chunk of PlacesSyncUtils.chunkArray(records, this._batchChunkSize)) {
await buf.store(chunk);
}
// Array of failed records.
return [];
},
async applyIncoming(record) {
let buf = await this.ensureOpenMirror();
await buf.store([record]);