Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: Source/devtools/front_end/resources/ServiceWorkerCacheViews.js

Issue 1044203004: [Storage] Cache storage inspection on all the frames! (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: comments and rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
10 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache 9 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache
11 */ 10 */
12 WebInspector.ServiceWorkerCacheView = function(model, cacheId, cache) 11 WebInspector.ServiceWorkerCacheView = function(model, cache)
13 { 12 {
14 WebInspector.VBox.call(this); 13 WebInspector.VBox.call(this);
15 this.registerRequiredCSS("resources/serviceWorkerCacheViews.css"); 14 this.registerRequiredCSS("resources/serviceWorkerCacheViews.css");
16 15
17 this._model = model; 16 this._model = model;
18 this._cacheId = cacheId;
19 17
20 this.element.classList.add("service-worker-cache-data-view"); 18 this.element.classList.add("service-worker-cache-data-view");
21 this.element.classList.add("storage-view"); 19 this.element.classList.add("storage-view");
22 20
23 this._createEditorToolbar(); 21 this._createEditorToolbar();
24 22
25 this._refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Refresh"), "refresh-toolbar-item"); 23 this._refreshButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Refresh"), "refresh-toolbar-item");
26 this._refreshButton.addEventListener("click", this._refreshButtonClicked, th is); 24 this._refreshButton.addEventListener("click", this._refreshButtonClicked, th is);
27 25
28 this._pageSize = 50; 26 this._pageSize = 50;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (this._dataGrid) 82 if (this._dataGrid)
85 this._dataGrid.detach(); 83 this._dataGrid.detach();
86 this._dataGrid = this._createDataGrid(); 84 this._dataGrid = this._createDataGrid();
87 this._dataGrid.show(this.element); 85 this._dataGrid.show(this.element);
88 86
89 this._skipCount = 0; 87 this._skipCount = 0;
90 this._updateData(true); 88 this._updateData(true);
91 }, 89 },
92 90
93 /** 91 /**
92 * @param {number} skipCount
93 * @param {!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>} entries
94 * @param {boolean} hasMore
95 * @this {WebInspector.ServiceWorkerCacheView}
96 */
97 _updateDataCallback(skipCount, entries, hasMore)
98 {
99 this._refreshButton.setEnabled(true);
100 this.clear();
101 this._entries = entries;
102 for (var i = 0; i < entries.length; ++i) {
103 var data = {};
104 data["number"] = i + skipCount;
105 data["request"] = entries[i].request;
106 data["response"] = entries[i].response;
107 var node = new WebInspector.SWCacheDataGridNode(data);
108 this._dataGrid.rootNode().appendChild(node);
109 }
110 this._pageBackButton.setEnabled(!!skipCount);
111 this._pageForwardButton.setEnabled(hasMore);
112 },
113
114 /**
94 * @param {boolean} force 115 * @param {boolean} force
95 */ 116 */
96 _updateData: function(force) 117 _updateData: function(force)
97 { 118 {
98 var pageSize = this._pageSize; 119 var pageSize = this._pageSize;
99 var skipCount = this._skipCount; 120 var skipCount = this._skipCount;
100 this._refreshButton.setEnabled(false); 121 this._refreshButton.setEnabled(false);
101 122
102 if (!force && this._lastPageSize === pageSize && this._lastSkipCount === skipCount) 123 if (!force && this._lastPageSize === pageSize && this._lastSkipCount === skipCount)
103 return; 124 return;
104 125
105 if (this._lastPageSize !== pageSize) { 126 if (this._lastPageSize !== pageSize) {
106 skipCount = 0; 127 skipCount = 0;
107 this._skipCount = 0; 128 this._skipCount = 0;
108 } 129 }
109 this._lastPageSize = pageSize; 130 this._lastPageSize = pageSize;
110 this._lastSkipCount = skipCount; 131 this._lastSkipCount = skipCount;
111 132 this._model.loadCacheData(this._cache, skipCount, pageSize, this._update DataCallback.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 }, 133 },
138 134
139 _refreshButtonClicked: function(event) 135 _refreshButtonClicked: function(event)
140 { 136 {
141 this._updateData(true); 137 this._updateData(true);
142 }, 138 },
143 139
144 /** 140 /**
145 * @return {!Array.<!WebInspector.ToolbarItem>} 141 * @return {!Array.<!WebInspector.ToolbarItem>}
146 */ 142 */
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 section.skipProto(); 197 section.skipProto();
202 cell.appendChild(section.element); 198 cell.appendChild(section.element);
203 } else { 199 } else {
204 valueElement.classList.add("primitive-value"); 200 valueElement.classList.add("primitive-value");
205 cell.appendChild(valueElement); 201 cell.appendChild(valueElement);
206 } 202 }
207 }, 203 },
208 204
209 __proto__: WebInspector.DataGridNode.prototype 205 __proto__: WebInspector.DataGridNode.prototype
210 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698