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

Side by Side Diff: content/browser/resources/media/cache_entry.js

Issue 23536020: Adds cache and buffer graphs to the properties pane. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 cr.define('media', function() { 5 cr.define('media', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * This class represents a file cached by net. 9 * This class represents a file cached by net.
10 */ 10 */
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 */ 169 */
170 drawCacheReadsToCanvas: function(canvas) { 170 drawCacheReadsToCanvas: function(canvas) {
171 this.drawCacheEntriesToCanvas(this.read_, '#0a0', canvas); 171 this.drawCacheEntriesToCanvas(this.read_, '#0a0', canvas);
172 }, 172 },
173 173
174 /** 174 /**
175 * Update this.details_ to contain everything we currently know about 175 * Update this.details_ to contain everything we currently know about
176 * this file. 176 * this file.
177 */ 177 */
178 generateDetails: function() { 178 generateDetails: function() {
179 function makeElement(tag, content) {
180 var toReturn = document.createElement(tag);
181 toReturn.appendChild(document.createTextNode(content));
182 return toReturn;
183 }
184
179 this.details_.id = this.key; 185 this.details_.id = this.key;
180 this.summaryText_.textContent = this.key || 'Unknown File'; 186 this.summaryText_.textContent = this.key || 'Unknown File';
181 187
182 this.detailTable_.textContent = ''; 188 this.detailTable_.textContent = '';
183 var header = document.createElement('thead'); 189 var header = document.createElement('thead');
184 var footer = document.createElement('tfoot'); 190 var footer = document.createElement('tfoot');
185 var body = document.createElement('tbody'); 191 var body = document.createElement('tbody');
186 this.detailTable_.appendChild(header); 192 this.detailTable_.appendChild(header);
187 this.detailTable_.appendChild(footer); 193 this.detailTable_.appendChild(footer);
188 this.detailTable_.appendChild(body); 194 this.detailTable_.appendChild(body);
189 195
190 var headerRow = document.createElement('tr'); 196 var headerRow = document.createElement('tr');
191 headerRow.appendChild(media.makeElement('th', 'Read From Cache')); 197 headerRow.appendChild(makeElement('th', 'Read From Cache'));
192 headerRow.appendChild(media.makeElement('th', 'Written To Cache')); 198 headerRow.appendChild(makeElement('th', 'Written To Cache'));
193 header.appendChild(headerRow); 199 header.appendChild(headerRow);
194 200
195 var footerRow = document.createElement('tr'); 201 var footerRow = document.createElement('tr');
196 var footerCell = document.createElement('td'); 202 var footerCell = document.createElement('td');
197 footerCell.textContent = 'Out of ' + (this.size || 'unkown size'); 203 footerCell.textContent = 'Out of ' + (this.size || 'unkown size');
198 footerCell.setAttribute('colspan', 2); 204 footerCell.setAttribute('colspan', 2);
199 footerRow.appendChild(footerCell); 205 footerRow.appendChild(footerCell);
200 footer.appendChild(footerRow); 206 footer.appendChild(footerRow);
201 207
202 var read = this.read_.map(function(start, end) { 208 var read = this.read_.map(function(start, end) {
203 return start + ' - ' + end; 209 return start + ' - ' + end;
204 }); 210 });
205 var written = this.written_.map(function(start, end) { 211 var written = this.written_.map(function(start, end) {
206 return start + ' - ' + end; 212 return start + ' - ' + end;
207 }); 213 });
208 214
209 var length = Math.max(read.length, written.length); 215 var length = Math.max(read.length, written.length);
210 for (var i = 0; i < length; i++) { 216 for (var i = 0; i < length; i++) {
211 var row = document.createElement('tr'); 217 var row = document.createElement('tr');
212 row.appendChild(media.makeElement('td', read[i] || '')); 218 row.appendChild(makeElement('td', read[i] || ''));
213 row.appendChild(media.makeElement('td', written[i] || '')); 219 row.appendChild(makeElement('td', written[i] || ''));
214 body.appendChild(row); 220 body.appendChild(row);
215 } 221 }
216 222
217 this.drawCacheWritesToCanvas(this.writeCanvas); 223 this.drawCacheWritesToCanvas(this.writeCanvas);
218 this.drawCacheReadsToCanvas(this.readCanvas); 224 this.drawCacheReadsToCanvas(this.readCanvas);
219 }, 225 },
220 226
221 /** 227 /**
222 * Render this CacheEntry as a <li>. 228 * Render this CacheEntry as a <li>.
223 * @return {HTMLElement} A <li> representing this CacheEntry. 229 * @return {HTMLElement} A <li> representing this CacheEntry.
224 */ 230 */
225 toListItem: function() { 231 toListItem: function() {
226 this.generateDetails(); 232 this.generateDetails();
227 233
228 var result = document.createElement('li'); 234 var result = document.createElement('li');
229 result.appendChild(this.details_); 235 result.appendChild(this.details_);
230 return result; 236 return result;
231 } 237 }
232 }; 238 };
233 239
234 return { 240 return {
235 CacheEntry: CacheEntry 241 CacheEntry: CacheEntry
236 }; 242 };
237 }); 243 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698