Last active
November 15, 2016 23:20
-
-
Save rhelmer/20446618789c5f8aaffb0b02316f9632 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) { | |
| @@ -765,31 +762,32 @@ this.XPIDatabase = { | |
| let readOptions = { | |
| outExecutionDuration: 0 | |
| }; | |
| return this._dbPromise = 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) { | |
| + | |
| + 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; | |
| }) | |
| - .then(null, | |
| + .catch( | |
| error => { | |
| - if (this._addonDB) { | |
| + if (this.addonDB) { | |
| logger.debug("Synchronous load completed while waiting for async load"); | |
| return this.addonDB; | |
| } | |
| if (error.becauseNoSuchFile) { | |
| this.upgradeDB(true); | |
| } | |
| else { | |
| // it's there but unreadable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment