From d5b88fb5662fbb74f0f1a06544199238ddfb26ce Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Thu, 14 Jul 2011 12:13:35 -0700 Subject: [PATCH] Bug 669913 - Viewing Sync quota blocks the entire Options window. r=rnewman Part 2: Use Service.getStorageInfo in the Quota dialog UI. --- browser/base/content/syncQuota.js | 31 ++++++++++++++++++++++-------- browser/base/content/syncQuota.xul | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/browser/base/content/syncQuota.js b/browser/base/content/syncQuota.js index 3984876cadf..2a3e86d9115 100644 --- a/browser/base/content/syncQuota.js +++ b/browser/base/content/syncQuota.js @@ -58,16 +58,21 @@ let gSyncQuota = { }, 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; } @@ -82,7 +87,17 @@ let gSyncQuota = { let total = gSyncQuota.convertKB(quota[1]); usageLabel.value = bundle.getFormattedString( "quota.usagePercentage.label", [percent].concat(used).concat(total)); - }, 0); + }); + }, + + onCancel: function onCancel() { + if (this._usage_req) { + this._usage_req.abort(); + } + if (this._quota_req) { + this._quota_req.abort(); + } + return true; }, onAccept: function onAccept() { @@ -95,7 +110,7 @@ let gSyncQuota = { let Service = Weave.Service; Weave.Utils.nextTick(function() { Service.sync(); }); } - return true; + return this.onCancel(); }, convertKB: function convertKB(value) { diff --git a/browser/base/content/syncQuota.xul b/browser/base/content/syncQuota.xul index ddbc643925b..fe10a876a5b 100644 --- a/browser/base/content/syncQuota.xul +++ b/browser/base/content/syncQuota.xul @@ -56,7 +56,7 @@ onload="gSyncQuota.init()" buttons="accept,cancel" title=""a.dialogTitle.label;" - ondialogcancel="return true;" + ondialogcancel="return gSyncQuota.onCancel();" ondialogaccept="return gSyncQuota.onAccept();">