Bug 804571: Implement download cancel (pause) for B2G. r=fabrice
authorMarshall Culpepper <marshall@mozilla.com>
Fri, 30 Nov 2012 13:35:54 -0600
changeset 114641 83c38674da8e1c190b00d82c9b867146c4437eed
parent 114640 b4f18037333507cf44c5bdbe1b77ff45f8d4a6bf
child 114642 70e354775e1bfa84f62119ca333785132fae8c28
push id18889
push usermculpepper@mozilla.com
push dateFri, 30 Nov 2012 19:37:28 +0000
treeherdermozilla-inbound@83c38674da8e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs804571
milestone20.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 804571: Implement download cancel (pause) for B2G. r=fabrice
b2g/components/UpdatePrompt.js
--- a/b2g/components/UpdatePrompt.js
+++ b/b2g/components/UpdatePrompt.js
@@ -255,20 +255,33 @@ UpdatePrompt.prototype = {
       case "restart":
         this.finishUpdate();
         this._update = null;
         break;
     }
   },
 
   downloadUpdate: function UP_downloadUpdate(aUpdate) {
+    if (!aUpdate) {
+      aUpdate = Services.um.activeUpdate;
+      if (!aUpdate) {
+        log("No active update found to download");
+        return;
+      }
+    }
+
     Services.aus.downloadUpdate(aUpdate, true);
     Services.aus.addDownloadListener(this);
   },
 
+  handleDownloadCancel: function UP_handleDownloadCancel() {
+    log("Pausing download");
+    Services.aus.pauseDownload();
+  },
+
   finishUpdate: function UP_finishUpdate() {
     if (!this._update.isOSUpdate) {
       // Standard gecko+gaia updates will just need to restart the process
       this.restartProcess();
       return;
     }
 
     let osApplyToDir;
@@ -342,16 +355,19 @@ UpdatePrompt.prototype = {
     switch (detail.type) {
       case "force-update-check":
         this.forceUpdateCheck();
         break;
       case "update-available-result":
         this.handleAvailableResult(detail);
         this._update = null;
         break;
+      case "update-download-cancel":
+        this.handleDownloadCancel();
+        break;
       case "update-prompt-apply-result":
         this.handleApplyPromptResult(detail);
         break;
     }
   },
 
   appsUpdated: function UP_appsUpdated(aApps) {
     log("appsUpdated: " + aApps.length + " apps to update");