зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
93cc71d46e
Коммит
977c5b0df9
|
@ -2741,7 +2741,7 @@ this.XPIProvider = {
|
||||||
|
|
||||||
logger.debug("startup");
|
logger.debug("startup");
|
||||||
this.runPhase = XPI_STARTING;
|
this.runPhase = XPI_STARTING;
|
||||||
this.installs = [];
|
this.installs = new Set();
|
||||||
this.installLocations = [];
|
this.installLocations = [];
|
||||||
this.installLocationsByName = {};
|
this.installLocationsByName = {};
|
||||||
// Hook for tests to detect when saving database at shutdown time fails
|
// Hook for tests to detect when saving database at shutdown time fails
|
||||||
|
@ -4202,13 +4202,7 @@ this.XPIProvider = {
|
||||||
* The AddonInstall to remove
|
* The AddonInstall to remove
|
||||||
*/
|
*/
|
||||||
removeActiveInstall: function(aInstall) {
|
removeActiveInstall: function(aInstall) {
|
||||||
let where = this.installs.indexOf(aInstall);
|
this.installs.delete(aInstall);
|
||||||
if (where == -1) {
|
|
||||||
logger.warn("removeActiveInstall: could not find active install for "
|
|
||||||
+ aInstall.sourceURI.spec);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.installs.splice(where, 1);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4287,7 +4281,7 @@ this.XPIProvider = {
|
||||||
* A callback to pass the array of AddonInstalls to
|
* A callback to pass the array of AddonInstalls to
|
||||||
*/
|
*/
|
||||||
getInstallsByTypes: function(aTypes, aCallback) {
|
getInstallsByTypes: function(aTypes, aCallback) {
|
||||||
let results = this.installs.slice(0);
|
let results = [...this.installs];
|
||||||
if (aTypes) {
|
if (aTypes) {
|
||||||
results = results.filter(install => {
|
results = results.filter(install => {
|
||||||
return aTypes.includes(getExternalType(install.type));
|
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.
|
// Giving each instance of AddonInstall a reference to the logger.
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|
||||||
|
XPIProvider.installs.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddonInstall.prototype = {
|
AddonInstall.prototype = {
|
||||||
|
@ -5453,16 +5449,19 @@ AddonInstall.prototype = {
|
||||||
this.icons = aManifest.icons;
|
this.icons = aManifest.icons;
|
||||||
this.releaseNotesURI = aManifest.releaseNotesURI ?
|
this.releaseNotesURI = aManifest.releaseNotesURI ?
|
||||||
NetUtil.newURI(aManifest.releaseNotesURI) :
|
NetUtil.newURI(aManifest.releaseNotesURI) :
|
||||||
null
|
null;
|
||||||
this.sourceURI = aManifest.sourceURI ?
|
this.sourceURI = aManifest.sourceURI ?
|
||||||
NetUtil.newURI(aManifest.sourceURI) :
|
NetUtil.newURI(aManifest.sourceURI) :
|
||||||
null;
|
null;
|
||||||
this.file = null;
|
this.file = this.sourceURI;
|
||||||
|
this._sourceBundle = this.sourceURI;
|
||||||
this.addon = aManifest;
|
this.addon = aManifest;
|
||||||
|
this.addon.sourceURI = this.sourceURI;
|
||||||
|
|
||||||
this.state = AddonManager.STATE_INSTALLED;
|
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");
|
logger.warn("XPI file " + this.file.path + " does not exist");
|
||||||
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
||||||
this.error = AddonManager.ERROR_NETWORK_FAILURE;
|
this.error = AddonManager.ERROR_NETWORK_FAILURE;
|
||||||
|
XPIProvider.removeActiveInstall(this);
|
||||||
aCallback(this);
|
aCallback(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5497,6 +5497,7 @@ AddonInstall.prototype = {
|
||||||
logger.warn("Unknown hash algorithm '" + this.hash.algorithm + "' for addon " + this.sourceURI.spec, e);
|
logger.warn("Unknown hash algorithm '" + this.hash.algorithm + "' for addon " + this.sourceURI.spec, e);
|
||||||
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
||||||
this.error = AddonManager.ERROR_INCORRECT_HASH;
|
this.error = AddonManager.ERROR_INCORRECT_HASH;
|
||||||
|
XPIProvider.removeActiveInstall(this);
|
||||||
aCallback(this);
|
aCallback(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5511,6 +5512,7 @@ AddonInstall.prototype = {
|
||||||
this.hash.data + ")");
|
this.hash.data + ")");
|
||||||
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
||||||
this.error = AddonManager.ERROR_INCORRECT_HASH;
|
this.error = AddonManager.ERROR_INCORRECT_HASH;
|
||||||
|
XPIProvider.removeActiveInstall(this);
|
||||||
aCallback(this);
|
aCallback(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5530,7 +5532,6 @@ AddonInstall.prototype = {
|
||||||
new UpdateChecker(this.addon, {
|
new UpdateChecker(this.addon, {
|
||||||
onUpdateFinished: aAddon => {
|
onUpdateFinished: aAddon => {
|
||||||
this.state = AddonManager.STATE_DOWNLOADED;
|
this.state = AddonManager.STATE_DOWNLOADED;
|
||||||
XPIProvider.installs.push(this);
|
|
||||||
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
||||||
this.listeners,
|
this.listeners,
|
||||||
this.wrapper);
|
this.wrapper);
|
||||||
|
@ -5540,7 +5541,6 @@ AddonInstall.prototype = {
|
||||||
}, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
|
}, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XPIProvider.installs.push(this);
|
|
||||||
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
||||||
this.listeners,
|
this.listeners,
|
||||||
this.wrapper);
|
this.wrapper);
|
||||||
|
@ -5552,6 +5552,7 @@ AddonInstall.prototype = {
|
||||||
logger.warn("Invalid XPI", message);
|
logger.warn("Invalid XPI", message);
|
||||||
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
this.state = AddonManager.STATE_DOWNLOAD_FAILED;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
XPIProvider.removeActiveInstall(this);
|
||||||
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
AddonManagerPrivate.callInstallListeners("onNewInstall",
|
||||||
this.listeners,
|
this.listeners,
|
||||||
this.wrapper);
|
this.wrapper);
|
||||||
|
@ -5583,7 +5584,6 @@ AddonInstall.prototype = {
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.maxProgress = -1;
|
this.maxProgress = -1;
|
||||||
|
|
||||||
XPIProvider.installs.push(this);
|
|
||||||
AddonManagerPrivate.callInstallListeners("onNewInstall", this.listeners,
|
AddonManagerPrivate.callInstallListeners("onNewInstall", this.listeners,
|
||||||
this.wrapper);
|
this.wrapper);
|
||||||
|
|
||||||
|
@ -5613,7 +5613,6 @@ AddonInstall.prototype = {
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.maxProgress = -1;
|
this.maxProgress = -1;
|
||||||
this.hash = this.originalHash;
|
this.hash = this.originalHash;
|
||||||
XPIProvider.installs.push(this);
|
|
||||||
this.startDownload();
|
this.startDownload();
|
||||||
break;
|
break;
|
||||||
case AddonManager.STATE_POSTPONED:
|
case AddonManager.STATE_POSTPONED:
|
||||||
|
@ -6671,6 +6670,7 @@ AddonInstall.createInstall = function(aCallback, aFile, aLocation = undefined) {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Error creating install", e);
|
logger.error("Error creating install", e);
|
||||||
|
XPIProvider.removeActiveInstall(this);
|
||||||
makeSafe(aCallback)(null);
|
makeSafe(aCallback)(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче