Bug 829052 - progress is NaN when doing appcache update; r=fabrice
authorFernando Jiménez <ferjmoreno@gmail.com>
Fri, 11 Jan 2013 11:58:33 +0100
changeset 118511 56e67e5e15482441def450399e40808ecb237ed4
parent 118510 4c0d5853f72b101d1519b90a888b2223d5c9556d
child 118512 a4d691c7bacbe01c0043a129d2590c5c17a525af
push id21116
push userferjmoreno@gmail.com
push dateFri, 11 Jan 2013 11:23:29 +0000
treeherdermozilla-inbound@56e67e5e1548 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs829052
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 829052 - progress is NaN when doing appcache update; r=fabrice
dom/apps/src/Webapps.js
dom/apps/src/Webapps.jsm
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -518,16 +518,17 @@ WebappsApplication.prototype = {
         }
         break;
       case "Webapps:OfflineCache":
         if (msg.manifest != this.manifestURL)
           return;
 
         if ("installState" in msg) {
           this.installState = msg.installState;
+          this.progress = msg.progress;
           if (this.installState == "installed") {
             this._downloadError = null;
             this.downloading = false;
             this._fireEvent("downloadsuccess", this._ondownloadsuccess);
             this._fireEvent("downloadapplied", this._ondownloadapplied);
           } else {
             this._fireEvent("downloadprogress", this._onprogress);
           }
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2551,27 +2551,29 @@ let AppcacheObserver = function(aApp) {
 AppcacheObserver.prototype = {
   // nsIOfflineCacheUpdateObserver implementation
   updateStateChanged: function appObs_Update(aUpdate, aState) {
     let mustSave = false;
     let app = this.app;
 
     debug("Offline cache state change for " + app.origin + " : " + aState);
 
-    let setStatus = function appObs_setStatus(aStatus) {
+    let setStatus = function appObs_setStatus(aStatus, aProgress) {
       debug("Offlinecache setStatus to " + aStatus + " for " + app.origin);
       mustSave = (app.installState != aStatus);
       app.installState = aStatus;
+      app.progress = aProgress;
       if (aStatus == "installed") {
         app.downloading = false;
         app.downloadAvailable = false;
       }
       DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
                                               { manifest: app.manifestURL,
-                                                installState: app.installState });
+                                                installState: app.installState,
+                                                progress: app.progress });
     }
 
     let setError = function appObs_setError(aError) {
       debug("Offlinecache setError to " + aError);
       DOMApplicationRegistry.broadcastMessage("Webapps:OfflineCache",
                                               { manifest: app.manifestURL,
                                                 error: aError });
       app.downloading = false;
@@ -2582,26 +2584,26 @@ AppcacheObserver.prototype = {
     switch (aState) {
       case Ci.nsIOfflineCacheUpdateObserver.STATE_ERROR:
         aUpdate.removeObserver(this);
         setError("APP_CACHE_DOWNLOAD_ERROR");
         break;
       case Ci.nsIOfflineCacheUpdateObserver.STATE_NOUPDATE:
       case Ci.nsIOfflineCacheUpdateObserver.STATE_FINISHED:
         aUpdate.removeObserver(this);
-        setStatus("installed");
+        setStatus("installed", aUpdate.byteProgress);
         break;
       case Ci.nsIOfflineCacheUpdateObserver.STATE_DOWNLOADING:
       case Ci.nsIOfflineCacheUpdateObserver.STATE_ITEMSTARTED:
-        setStatus(this.startStatus);
+        setStatus(this.startStatus, aUpdate.byteProgress);
         break;
       case Ci.nsIOfflineCacheUpdateObserver.STATE_ITEMPROGRESS:
         let now = Date.now();
         if (now - this.lastProgressTime > MIN_PROGRESS_EVENT_DELAY) {
-          setStatus(this.startStatus);
+          setStatus(this.startStatus, aUpdate.byteProgress);
           this.lastProgressTime = now;
         }
         break;
     }
 
     // Status changed, update the stored version.
     if (mustSave) {
       DOMApplicationRegistry._saveApps();