Last active
November 15, 2016 19:19
-
-
Save rhelmer/9730fc1b5fbb4d36d944b6ea473189ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js | |
| --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js | |
| +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js | |
| @@ -614,24 +614,21 @@ this.XPIDatabase = { | |
| else { | |
| this.rebuildUnreadableDB(e, aRebuildOnError); | |
| } | |
| } | |
| finally { | |
| 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); | |
| }, | |
| /** | |
| * Parse loaded data, reconstructing the database if the loaded data is not valid | |
| * @param aRebuildOnError | |
| * If true, synchronously reconstruct the database from installed add-ons | |
| */ | |
| parseDB: function(aData, aRebuildOnError) { | |
| @@ -760,48 +757,48 @@ this.XPIDatabase = { | |
| return this._dbPromise; | |
| } | |
| logger.debug("Starting async load of XPI database " + this.jsonFile.path); | |
| AddonManagerPrivate.recordSimpleMeasure("XPIDB_async_load", XPIProvider.runPhase); | |
| let readOptions = { | |
| outExecutionDuration: 0 | |
| }; | |
| - return this._dbPromise = OS.File.read(this.jsonFile.path, null, readOptions).then( | |
| - byteArray => { | |
| + return this._dbPromise = new Promise((resolve, reject) => { | |
| + OS.File.read(this.jsonFile.path, null, readOptions).then(byteArray => { | |
| logger.debug("Async JSON file read took " + readOptions.outExecutionDuration + " MS"); | |
| AddonManagerPrivate.recordSimpleMeasure("XPIDB_asyncRead_MS", | |
| readOptions.outExecutionDuration); | |
| if (this._addonDB) { | |
| logger.debug("Synchronous load completed while waiting for async load"); | |
| return this.addonDB; | |
| } | |
| logger.debug("Finished async read of XPI database, parsing..."); | |
| let decodeTimer = AddonManagerPrivate.simpleTimer("XPIDB_decode_MS"); | |
| let decoder = new TextDecoder(); | |
| let data = decoder.decode(byteArray); | |
| decodeTimer.done(); | |
| this.parseDB(data, true); | |
| - return this.addonDB; | |
| + return resolve(this.addonDB); | |
| }) | |
| - .then(null, | |
| - error => { | |
| + .then(null, error => { | |
| if (this._addonDB) { | |
| logger.debug("Synchronous load completed while waiting for async load"); | |
| - return this.addonDB; | |
| + return reject(this.addonDB); | |
| } | |
| if (error.becauseNoSuchFile) { | |
| this.upgradeDB(true); | |
| } | |
| else { | |
| // it's there but unreadable | |
| this.rebuildUnreadableDB(error, true); | |
| } | |
| - return this.addonDB; | |
| + return resolve(this.addonDB); | |
| }); | |
| + }); | |
| }, | |
| /** | |
| * Rebuild the database from addon install directories. If this.migrateData | |
| * is available, uses migrated information for settings on the addons found | |
| * during rebuild | |
| * @param aRebuildOnError | |
| * A boolean indicating whether add-on information should be loaded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment