Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 /** | |
| 32 * @constructor | |
| 33 * @extends {WebInspector.View} | |
| 34 * @param {string} securityOrigin | |
| 35 */ | |
| 36 WebInspector.QuotaView = function(securityOrigin) | |
| 37 { | |
| 38 WebInspector.View.call(this); | |
| 39 this.securityOrigin = securityOrigin; | |
| 40 | |
| 41 this.element.addStyleClass("storage-view"); | |
| 42 this.element.addStyleClass("table"); | |
| 43 | |
| 44 this.refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString( "Refresh"), "refresh-storage-status-bar-item"); | |
| 45 this.refreshButton.addEventListener("click", this._refreshButtonClicked, thi s); | |
| 46 } | |
| 47 | |
| 48 WebInspector.QuotaView.prototype = { | |
| 49 get statusBarItems() | |
| 50 { | |
| 51 return [this.refreshButton.element]; | |
| 52 }, | |
| 53 | |
| 54 wasShown: function() | |
| 55 { | |
| 56 this._update(); | |
| 57 }, | |
| 58 | |
| 59 /* | |
| 60 * @param {?Protocol.Error} error | |
| 61 * @param {QuotaAgent.Quota} quota | |
| 62 * @param {QuotaAgent.Usage} usage | |
| 63 */ | |
| 64 _showUsageAndQuota: function(error, quota, usage) | |
| 65 { | |
| 66 var columns = [ | |
|
aandrey
2013/09/20 08:31:59
check error?
SeRya
2013/09/27 13:31:01
Done.
| |
| 67 {id: "key", title: WebInspector.UIString("Key"), editable: true, wei ght: 50}, | |
| 68 {id: "value", title: WebInspector.UIString("Value"), editable: true, weight: 50} | |
| 69 ]; | |
| 70 | |
| 71 var items = [ | |
| 72 { name: WebInspector.UIString("Available space"), value: Number.byte sToString(quota.availableSpace) }, | |
| 73 { name: WebInspector.UIString("Temporary global quota"), value: Numb er.bytesToString(quota.temporaryGlobalQuota) }, | |
| 74 { name: WebInspector.UIString("Persistent host quota"), value: Numbe r.bytesToString(quota.persistentHostQuota) }, | |
| 75 { name: WebInspector.UIString("Temporary file system usage"), value: Number.bytesToString(usage.temporaryFileSystemUsage) }, | |
| 76 { name: WebInspector.UIString("Persistent file system usage"), value : Number.bytesToString(usage.persistentFileSystemUsage) }, | |
| 77 { name: WebInspector.UIString("Syncable file system usage"), value: Number.bytesToString(usage.syncableFileSystemUsage) }, | |
| 78 { name: WebInspector.UIString("Web SQL usage"), value: Number.bytesT oString(usage.databaseUsage) }, | |
| 79 { name: WebInspector.UIString("Application Cache usage"), value: Num ber.bytesToString(usage.appcacheUsage) }, | |
| 80 { name: WebInspector.UIString("IndexedDB usage"), value: Number.byte sToString(usage.indexedDatabaseUsage) } | |
| 81 ]; | |
| 82 var dataGrid = new WebInspector.DataGrid(columns); | |
| 83 dataGrid.setName("QuotaItemsView"); | |
| 84 | |
| 85 for (var i = 0; i < items.length; i++) | |
| 86 dataGrid.rootNode().appendChild(new WebInspector.DataGridNode({key: items[i].name, value: items[i].value}, false)); | |
| 87 | |
| 88 dataGrid.show(this.element); | |
| 89 }, | |
| 90 | |
| 91 _refreshButtonClicked: function(event) | |
| 92 { | |
| 93 this._update(); | |
| 94 }, | |
| 95 | |
| 96 _update: function() | |
| 97 { | |
| 98 this.detachChildViews(); | |
| 99 PageAgent.queryUsageAndQuota(this.securityOrigin, this._showUsageAndQuot a.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
| |
| 100 }, | |
| 101 | |
| 102 __proto__: WebInspector.View.prototype | |
| 103 } | |
| 104 | |
| OLD | NEW |