Bug 1313960 - synchronous addon DB loader should handle in-progress async load r=kmag

MozReview-Commit-ID: LwzmRr3PdXx

--HG--
extra : rebase_source : d8c8aa7c3974fe88f4b6228a157dc3140c664980
This commit is contained in:
Robert Helmer 2016-11-15 13:40:47 -08:00
Родитель f4b410fd2f
Коммит 2ac6133e12
1 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -619,14 +619,11 @@ this.XPIDatabase = {
if (fstream)
fstream.close();
}
// If an async load was also in progress, resolve that promise with our DB;
// otherwise create a resolved promise
// If an async load was also in progress, record in telemetry.
if (this._dbPromise) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_overlapped_load", 1);
this._dbPromise.resolve(this.addonDB);
}
else
this._dbPromise = Promise.resolve(this.addonDB);
this._dbPromise = Promise.resolve(this.addonDB);
},
/**
@ -770,7 +767,8 @@ this.XPIDatabase = {
logger.debug("Async JSON file read took " + readOptions.outExecutionDuration + " MS");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_asyncRead_MS",
readOptions.outExecutionDuration);
if (this._addonDB) {
if (this.addonDB) {
logger.debug("Synchronous load completed while waiting for async load");
return this.addonDB;
}
@ -782,9 +780,9 @@ this.XPIDatabase = {
this.parseDB(data, true);
return this.addonDB;
})
.then(null,
.catch(
error => {
if (this._addonDB) {
if (this.addonDB) {
logger.debug("Synchronous load completed while waiting for async load");
return this.addonDB;
}