Index: Source/devtools/front_end/QuotaView.js |
diff --git a/Source/devtools/front_end/QuotaView.js b/Source/devtools/front_end/QuotaView.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7628fa2d81ecd9008ee7c0d7db548b69815a1852 |
--- /dev/null |
+++ b/Source/devtools/front_end/QuotaView.js |
@@ -0,0 +1,104 @@ |
+/* |
+ * Copyright (C) 2013 Google Inc. All rights reserved. |
+ * |
+ * Redistribution and use in source and binary forms, with or without |
+ * modification, are permitted provided that the following conditions are |
+ * met: |
+ * |
+ * * Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * * Redistributions in binary form must reproduce the above |
+ * copyright notice, this list of conditions and the following disclaimer |
+ * in the documentation and/or other materials provided with the |
+ * distribution. |
+ * * Neither the name of Google Inc. nor the names of its |
+ * contributors may be used to endorse or promote products derived from |
+ * this software without specific prior written permission. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ */ |
+ |
+/** |
+ * @constructor |
+ * @extends {WebInspector.View} |
+ * @param {string} securityOrigin |
+ */ |
+WebInspector.QuotaView = function(securityOrigin) |
+{ |
+ WebInspector.View.call(this); |
+ this.securityOrigin = securityOrigin; |
+ |
+ this.element.addStyleClass("storage-view"); |
+ this.element.addStyleClass("table"); |
+ |
+ this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString("Refresh"), "refresh-storage-status-bar-item"); |
+ this.refreshButton.addEventListener("click", this._refreshButtonClicked, this); |
+} |
+ |
+WebInspector.QuotaView.prototype = { |
+ get statusBarItems() |
+ { |
+ return [this.refreshButton.element]; |
+ }, |
+ |
+ wasShown: function() |
+ { |
+ this._update(); |
+ }, |
+ |
+ /* |
+ * @param {?Protocol.Error} error |
+ * @param {QuotaAgent.Quota} quota |
+ * @param {QuotaAgent.Usage} usage |
+ */ |
+ _showUsageAndQuota: function(error, quota, usage) |
+ { |
+ var columns = [ |
aandrey
2013/09/20 08:31:59
check error?
SeRya
2013/09/27 13:31:01
Done.
|
+ {id: "key", title: WebInspector.UIString("Key"), editable: true, weight: 50}, |
+ {id: "value", title: WebInspector.UIString("Value"), editable: true, weight: 50} |
+ ]; |
+ |
+ var items = [ |
+ { name: WebInspector.UIString("Available space"), value: Number.bytesToString(quota.availableSpace) }, |
+ { name: WebInspector.UIString("Temporary global quota"), value: Number.bytesToString(quota.temporaryGlobalQuota) }, |
+ { name: WebInspector.UIString("Persistent host quota"), value: Number.bytesToString(quota.persistentHostQuota) }, |
+ { name: WebInspector.UIString("Temporary file system usage"), value: Number.bytesToString(usage.temporaryFileSystemUsage) }, |
+ { name: WebInspector.UIString("Persistent file system usage"), value: Number.bytesToString(usage.persistentFileSystemUsage) }, |
+ { name: WebInspector.UIString("Syncable file system usage"), value: Number.bytesToString(usage.syncableFileSystemUsage) }, |
+ { name: WebInspector.UIString("Web SQL usage"), value: Number.bytesToString(usage.databaseUsage) }, |
+ { name: WebInspector.UIString("Application Cache usage"), value: Number.bytesToString(usage.appcacheUsage) }, |
+ { name: WebInspector.UIString("IndexedDB usage"), value: Number.bytesToString(usage.indexedDatabaseUsage) } |
+ ]; |
+ var dataGrid = new WebInspector.DataGrid(columns); |
+ dataGrid.setName("QuotaItemsView"); |
+ |
+ for (var i = 0; i < items.length; i++) |
+ dataGrid.rootNode().appendChild(new WebInspector.DataGridNode({key: items[i].name, value: items[i].value}, false)); |
+ |
+ dataGrid.show(this.element); |
+ }, |
+ |
+ _refreshButtonClicked: function(event) |
+ { |
+ this._update(); |
+ }, |
+ |
+ _update: function() |
+ { |
+ this.detachChildViews(); |
+ PageAgent.queryUsageAndQuota(this.securityOrigin, this._showUsageAndQuota.bind(this)); |
aandrey
2013/09/20 08:31:59
fyi. if this is expensive in the backend, you shou
SeRya
2013/09/27 13:31:01
It usually needs to find a proper ClientUsageTrack
|
+ }, |
+ |
+ __proto__: WebInspector.View.prototype |
+} |
+ |