Bug 675255 - Port part 2 of |Bug 669913 - Viewing Sync quota blocks the entire Options window|. r=Neil
authorJens Hatlak <jh@junetz.de>
Fri, 29 Jul 2011 22:42:13 +0200
changeset 8379 cfb57e11ca398adcc3f44ee2dd6da554b8794ad5
parent 8378 1dbfc673bc3f4b223a1a418e72d17ebdc7a48cfb
child 8380 3309b98f01df5767a394fb32e0d7a114d2466ab1
push id107
push userbugzilla@standard8.plus.com
push dateTue, 16 Aug 2011 23:11:19 +0000
treeherdercomm-aurora@cefe50ba1568 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs675255, 669913
Bug 675255 - Port part 2 of |Bug 669913 - Viewing Sync quota blocks the entire Options window|. r=Neil
suite/common/sync/syncQuota.js
suite/common/sync/syncQuota.xul
--- a/suite/common/sync/syncQuota.js
+++ b/suite/common/sync/syncQuota.js
@@ -53,41 +53,51 @@ let gSyncQuota = {
     gUsageTreeView.init();
     this.tree = document.getElementById("usageTree");
     this.tree.view = gUsageTreeView;
 
     this.loadData();
   },
 
   loadData: function loadData() {
-    window.setTimeout(function() {
-      let usage = Weave.Service.getCollectionUsage();
+    this._usage_req = Weave.Service.getStorageInfo(Weave.INFO_COLLECTION_USAGE,
+                                                   function (error, usage) {
+      delete gSyncQuota._usage_req;
+      // displayUsageData handles null values, so no need to check 'error'.
       gUsageTreeView.displayUsageData(usage);
-    }, 0);
+    });
 
     let usageLabel = document.getElementById("usageLabel");
     let bundle = this.bundle;
-    window.setTimeout(function() {
-      let quota = Weave.Service.getQuota();
-      if (!quota) {
+    this._quota_req = Weave.Service.getStorageInfo(Weave.INFO_QUOTA,
+                                                   function (error, quota) {
+      delete gSyncQuota._quota_req;
+      if (error) {
         usageLabel.value = bundle.getString("quota.usageError.label");
         return;
       }
       let used = gSyncQuota.convertKB(quota[0]);
       if (!quota[1]) {
         // No quota on the server.
         usageLabel.value = bundle.getFormattedString(
           "quota.usageNoQuota.label", used);
         return;
       }
       let percent = Math.round(100 * quota[0] / quota[1]);
       let total = gSyncQuota.convertKB(quota[1]);
       usageLabel.value = bundle.getFormattedString(
         "quota.usagePercentage.label", [percent].concat(used).concat(total));
-    }, 0);
+    });
+  },
+
+  uninit: function uninit() {
+    if (this._usage_req)
+      this._usage_req.abort();
+    if (this._quota_req)
+      this._quota_req.abort();
   },
 
   onAccept: function onAccept() {
     let engines = gUsageTreeView.getEnginesToDisable();
     for each (let engine in engines) {
       Weave.Engines.get(engine).enabled = false;
     }
     if (engines.length) {
--- a/suite/common/sync/syncQuota.xul
+++ b/suite/common/sync/syncQuota.xul
@@ -48,19 +48,19 @@
 %syncBrandDTD;
 %syncQuotaDTD;
 ]>
 <dialog id="quotaDialog"
         windowtype="Sync:ViewQuota"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         onload="gSyncQuota.init();"
+        onunload="gSyncQuota.uninit();"
         buttons="accept,cancel"
         title="&quota.dialogTitle.label;"
-        ondialogcancel="return true;"
         ondialogaccept="return gSyncQuota.onAccept();">
 
   <script type="application/javascript"
           src="chrome://communicator/content/sync/syncQuota.js"/>
 
   <stringbundleset id="stringbundleset">
     <stringbundle id="quotaStrings"
                   src="chrome://communicator/locale/sync/syncQuota.properties"/>