Bug 839810 - Race condition installing apps on linux r=ferjm

This commit is contained in:
Fabrice Desré 2013-02-13 11:55:45 -08:00
parent 9e263c0408
commit cf5abb85cf
2 changed files with 30 additions and 1 deletions

View File

@ -45,6 +45,8 @@ WebappsRegistry.prototype = {
switch (aMessage.name) {
case "Webapps:Install:Return:OK":
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app));
cpmm.sendAsyncMessage("Webapps:Install:Return:Ack",
{ manifestURL : app.manifestURL });
break;
case "Webapps:Install:Return:KO":
Services.DOMRequest.fireError(req, msg.error || "DENIED");

View File

@ -80,6 +80,7 @@ this.DOMApplicationRegistry = {
"Webapps:UnregisterForMessages",
"Webapps:CancelDownload", "Webapps:CheckForUpdate",
"Webapps:Download", "Webapps:ApplyDownload",
"Webapps:Install:Return:Ack",
"child-process-shutdown"];
this.frameMessages = ["Webapps:ClearBrowserData"];
@ -853,6 +854,9 @@ this.DOMApplicationRegistry = {
case "Activities:Register:OK":
this.notifyAppsRegistryReady();
break;
case "Webapps:Install:Return:Ack":
this.onInstallSuccessAck(msg.manifestURL);
break;
}
},
@ -1764,6 +1768,23 @@ this.DOMApplicationRegistry = {
aData.mm.sendAsyncMessage("Webapps:Install:Return:KO", aData);
},
// This function is called after we called the onsuccess callback on the
// content side. This let the webpage the opportunity to set event handlers
// on the app before we start firing progress events.
queuedDownload: {},
onInstallSuccessAck: function onInstallSuccessAck(aManifestURL) {
let download = this.queuedDownload[aManifestURL];
if (!download) {
return;
}
this.startOfflineCacheDownload(download.manifest,
download.app,
download.profileDir,
download.offlineCacheObserver);
delete this.queuedDownload[aManifestURL];
},
confirmInstall: function(aData, aFromSync, aProfileDir, aOfflineCacheObserver) {
let isReinstall = false;
let app = aData.app;
@ -1866,6 +1887,13 @@ this.DOMApplicationRegistry = {
aData.app[aProp] = appObject[aProp];
});
this.queuedDownload[app.manifestURL] = {
manifest: manifest,
app: appObject,
profileDir: aProfileDir,
offlineCacheObserver: aOfflineCacheObserver
}
if (!aFromSync)
this._saveApps((function() {
this.broadcastMessage("Webapps:Install:Return:OK", aData);
@ -1884,7 +1912,6 @@ this.DOMApplicationRegistry = {
#endif
}
this.startOfflineCacheDownload(manifest, appObject, aProfileDir, aOfflineCacheObserver);
if (manifest.package_path) {
// origin for install apps is meaningless here, since it's app:// and this
// can't be used to resolve package paths.