OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
8 * @param {!WebInspector.ServiceWorkerCacheModel} model | 8 * @param {!WebInspector.ServiceWorkerCacheModel} model |
9 * @param {!WebInspector.ServiceWorkerCacheModel.CacheId} cacheId | 9 * @param {!WebInspector.ServiceWorkerCacheModel.CacheId} cacheId |
10 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache | 10 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (this._dataGrid) | 84 if (this._dataGrid) |
85 this._dataGrid.detach(); | 85 this._dataGrid.detach(); |
86 this._dataGrid = this._createDataGrid(); | 86 this._dataGrid = this._createDataGrid(); |
87 this._dataGrid.show(this.element); | 87 this._dataGrid.show(this.element); |
88 | 88 |
89 this._skipCount = 0; | 89 this._skipCount = 0; |
90 this._updateData(true); | 90 this._updateData(true); |
91 }, | 91 }, |
92 | 92 |
93 /** | 93 /** |
| 94 * @param {number} skipCount |
| 95 * @param {!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>} entries |
| 96 * @param {boolean} hasMore |
| 97 * @this {WebInspector.ServiceWorkerCacheView} |
| 98 */ |
| 99 _updateDataCallback(skipCount, entries, hasMore) |
| 100 { |
| 101 this._refreshButton.setEnabled(true); |
| 102 this.clear(); |
| 103 this._entries = entries; |
| 104 for (var i = 0; i < entries.length; ++i) { |
| 105 var data = {}; |
| 106 data["number"] = i + skipCount; |
| 107 data["request"] = entries[i].request; |
| 108 data["response"] = entries[i].response; |
| 109 var node = new WebInspector.SWCacheDataGridNode(data); |
| 110 this._dataGrid.rootNode().appendChild(node); |
| 111 } |
| 112 this._pageBackButton.setEnabled(!!skipCount); |
| 113 this._pageForwardButton.setEnabled(hasMore); |
| 114 }, |
| 115 |
| 116 /** |
94 * @param {boolean} force | 117 * @param {boolean} force |
95 */ | 118 */ |
96 _updateData: function(force) | 119 _updateData: function(force) |
97 { | 120 { |
98 var pageSize = this._pageSize; | 121 var pageSize = this._pageSize; |
99 var skipCount = this._skipCount; | 122 var skipCount = this._skipCount; |
100 this._refreshButton.setEnabled(false); | 123 this._refreshButton.setEnabled(false); |
101 | 124 |
102 if (!force && this._lastPageSize === pageSize && this._lastSkipCount ===
skipCount) | 125 if (!force && this._lastPageSize === pageSize && this._lastSkipCount ===
skipCount) |
103 return; | 126 return; |
104 | 127 |
105 if (this._lastPageSize !== pageSize) { | 128 if (this._lastPageSize !== pageSize) { |
106 skipCount = 0; | 129 skipCount = 0; |
107 this._skipCount = 0; | 130 this._skipCount = 0; |
108 } | 131 } |
109 this._lastPageSize = pageSize; | 132 this._lastPageSize = pageSize; |
110 this._lastSkipCount = skipCount; | 133 this._lastSkipCount = skipCount; |
111 | 134 this._model.loadCacheData(this._cacheId, skipCount, pageSize, this._upda
teDataCallback.bind(this, skipCount)); |
112 /** | |
113 * @param {!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>} entries | |
114 * @param {boolean} hasMore | |
115 * @this {WebInspector.ServiceWorkerCacheView} | |
116 */ | |
117 function callback(entries, hasMore) | |
118 { | |
119 this._refreshButton.setEnabled(true); | |
120 this.clear(); | |
121 this._entries = entries; | |
122 for (var i = 0; i < entries.length; ++i) { | |
123 var data = {}; | |
124 data["number"] = i + skipCount; | |
125 data["request"] = entries[i].request; | |
126 data["response"] = entries[i].response; | |
127 | |
128 var node = new WebInspector.SWCacheDataGridNode(data); | |
129 this._dataGrid.rootNode().appendChild(node); | |
130 } | |
131 | |
132 this._pageBackButton.setEnabled(!!skipCount); | |
133 this._pageForwardButton.setEnabled(hasMore); | |
134 } | |
135 | |
136 this._model.loadCacheData(this._cacheId, skipCount, pageSize, callback.b
ind(this)); | |
137 }, | 135 }, |
138 | 136 |
139 _refreshButtonClicked: function(event) | 137 _refreshButtonClicked: function(event) |
140 { | 138 { |
141 this._updateData(true); | 139 this._updateData(true); |
142 }, | 140 }, |
143 | 141 |
144 /** | 142 /** |
145 * @return {!Array.<!WebInspector.StatusBarItem>} | 143 * @return {!Array.<!WebInspector.StatusBarItem>} |
146 */ | 144 */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 section.skipProto(); | 199 section.skipProto(); |
202 cell.appendChild(section.element); | 200 cell.appendChild(section.element); |
203 } else { | 201 } else { |
204 valueElement.classList.add("primitive-value"); | 202 valueElement.classList.add("primitive-value"); |
205 cell.appendChild(valueElement); | 203 cell.appendChild(valueElement); |
206 } | 204 } |
207 }, | 205 }, |
208 | 206 |
209 __proto__: WebInspector.DataGridNode.prototype | 207 __proto__: WebInspector.DataGridNode.prototype |
210 } | 208 } |
OLD | NEW |