Bug 838561 - If we try to start a download or check for updates but we are already downloading, ignore the call. r=fabrice
authorJulien Wajsberg <jwajsberg@mozilla.com>
Fri, 08 Feb 2013 10:40:52 +0100
changeset 131211 eca4d9c0301b9c293ba8f5342d3d3f4c3bb59afb
parent 131210 a245131609227d6cd6d5d28d38042a680bbfb824
child 131212 272789a888359ef27d625e15162d159b666452fd
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs838561
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 838561 - If we try to start a download or check for updates but we are already downloading, ignore the call. r=fabrice
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -963,16 +963,21 @@ this.DOMApplicationRegistry = {
     debug("startDownload for " + aManifestURL);
     let id = this._appIdForManifestURL(aManifestURL);
     let app = this.webapps[id];
     if (!app) {
       debug("startDownload: No app found for " + aManifestURL);
       return;
     }
 
+    if (app.downloading) {
+      debug("app is already downloading. Ignoring.");
+      return;
+    }
+
     // If the caller is trying to start a download but we have nothing to
     // download, send an error.
     if (!app.downloadAvailable) {
       this.broadcastMessage("Webapps:PackageEvent",
                             { type: "canceled",
                               manifestURL: app.manifestURL,
                               app: app,
                               error: "NO_DOWNLOAD_AVAILABLE" });
@@ -1254,28 +1259,35 @@ this.DOMApplicationRegistry = {
     }
 
     // Convert the binary hash data to a hex string.
     return [toHexString(hash.charCodeAt(i)) for (i in hash)].join("");
   },
 
   checkForUpdate: function(aData, aMm) {
     debug("checkForUpdate for " + aData.manifestURL);
+
+    function sendError(aError) {
+      aData.error = aError;
+      aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
+    }
+
     let id = this._appIdForManifestURL(aData.manifestURL);
     let app = this.webapps[id];
 
     if (!app) {
-      aData.error = "NO_SUCH_APP";
-      aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
+      sendError("NO_SUCH_APP");
       return;
     }
 
-    function sendError(aError) {
-      aData.error = aError;
-      aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
+    // we may be able to remove this when this bug is fixed:
+    // https://bugzilla.mozilla.org/show_bug.cgi?id=839071
+    if (app.downloading) {
+      sendError("APP_IS_DOWNLOADING");
+      return;
     }
 
     function updatePackagedApp(aManifest) {
       debug("updatePackagedApp");
 
       // if the app manifestURL has a app:// scheme, we can't have an
       // update.
       if (app.manifestURL.startsWith("app://")) {