Bug 1315407 Revise tracking of active AddonInstalls r=rhelmer

MozReview-Commit-ID: Is3RMjSN6Bw

--HG--
extra : rebase_source : 87cc0078e73ceae0f0196729c446f56977332637
extra : intermediate-source : c47e12b63929919f9fdecad4aea1aeea0ed41cd0
extra : source : 67088f2c1a9c13b471ddeb57e874ce15c72dc014
This commit is contained in:
Andrew Swan 2016-11-10 12:49:27 -08:00
Родитель 93cc71d46e
Коммит 977c5b0df9
1 изменённых файлов: 16 добавлений и 16 удалений

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

@ -2741,7 +2741,7 @@ this.XPIProvider = {
logger.debug("startup");
this.runPhase = XPI_STARTING;
this.installs = [];
this.installs = new Set();
this.installLocations = [];
this.installLocationsByName = {};
// Hook for tests to detect when saving database at shutdown time fails
@ -4202,13 +4202,7 @@ this.XPIProvider = {
* The AddonInstall to remove
*/
removeActiveInstall: function(aInstall) {
let where = this.installs.indexOf(aInstall);
if (where == -1) {
logger.warn("removeActiveInstall: could not find active install for "
+ aInstall.sourceURI.spec);
return;
}
this.installs.splice(where, 1);
this.installs.delete(aInstall);
},
/**
@ -4287,7 +4281,7 @@ this.XPIProvider = {
* A callback to pass the array of AddonInstalls to
*/
getInstallsByTypes: function(aTypes, aCallback) {
let results = this.installs.slice(0);
let results = [...this.installs];
if (aTypes) {
results = results.filter(install => {
return aTypes.includes(getExternalType(install.type));
@ -5406,6 +5400,8 @@ function AddonInstall(aInstallLocation, aUrl, aHash, aReleaseNotesURI,
// Giving each instance of AddonInstall a reference to the logger.
this.logger = logger;
XPIProvider.installs.add(this);
}
AddonInstall.prototype = {
@ -5453,16 +5449,19 @@ AddonInstall.prototype = {
this.icons = aManifest.icons;
this.releaseNotesURI = aManifest.releaseNotesURI ?
NetUtil.newURI(aManifest.releaseNotesURI) :
null
null;
this.sourceURI = aManifest.sourceURI ?
NetUtil.newURI(aManifest.sourceURI) :
null;
this.file = null;
this.file = this.sourceURI;
this._sourceBundle = this.sourceURI;
this.addon = aManifest;
this.addon.sourceURI = this.sourceURI;
this.state = AddonManager.STATE_INSTALLED;
XPIProvider.installs.push(this);
XPIProvider.installs.add(this);
return this;
},
/**
@ -5479,6 +5478,7 @@ AddonInstall.prototype = {
logger.warn("XPI file " + this.file.path + " does not exist");
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
this.error = AddonManager.ERROR_NETWORK_FAILURE;
XPIProvider.removeActiveInstall(this);
aCallback(this);
return;
}
@ -5497,6 +5497,7 @@ AddonInstall.prototype = {
logger.warn("Unknown hash algorithm '" + this.hash.algorithm + "' for addon " + this.sourceURI.spec, e);
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
this.error = AddonManager.ERROR_INCORRECT_HASH;
XPIProvider.removeActiveInstall(this);
aCallback(this);
return;
}
@ -5511,6 +5512,7 @@ AddonInstall.prototype = {
this.hash.data + ")");
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
this.error = AddonManager.ERROR_INCORRECT_HASH;
XPIProvider.removeActiveInstall(this);
aCallback(this);
return;
}
@ -5530,7 +5532,6 @@ AddonInstall.prototype = {
new UpdateChecker(this.addon, {
onUpdateFinished: aAddon => {
this.state = AddonManager.STATE_DOWNLOADED;
XPIProvider.installs.push(this);
AddonManagerPrivate.callInstallListeners("onNewInstall",
this.listeners,
this.wrapper);
@ -5540,7 +5541,6 @@ AddonInstall.prototype = {
}, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
}
else {
XPIProvider.installs.push(this);
AddonManagerPrivate.callInstallListeners("onNewInstall",
this.listeners,
this.wrapper);
@ -5552,6 +5552,7 @@ AddonInstall.prototype = {
logger.warn("Invalid XPI", message);
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
this.error = error;
XPIProvider.removeActiveInstall(this);
AddonManagerPrivate.callInstallListeners("onNewInstall",
this.listeners,
this.wrapper);
@ -5583,7 +5584,6 @@ AddonInstall.prototype = {
this.progress = 0;
this.maxProgress = -1;
XPIProvider.installs.push(this);
AddonManagerPrivate.callInstallListeners("onNewInstall", this.listeners,
this.wrapper);
@ -5613,7 +5613,6 @@ AddonInstall.prototype = {
this.progress = 0;
this.maxProgress = -1;
this.hash = this.originalHash;
XPIProvider.installs.push(this);
this.startDownload();
break;
case AddonManager.STATE_POSTPONED:
@ -6671,6 +6670,7 @@ AddonInstall.createInstall = function(aCallback, aFile, aLocation = undefined) {
}
catch (e) {
logger.error("Error creating install", e);
XPIProvider.removeActiveInstall(this);
makeSafe(aCallback)(null);
}
};