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

Side by Side Diff: chrome/browser/resources/task_scheduler_internals/index.js

Issue 2420973002: Plumb Task Scheduler Histograms to the Task Scheduler Internals Page (Closed)
Patch Set: CR Feedback Created 4 years, 2 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var TaskSchedulerInternals = {};
Dan Beam 2016/10/29 01:13:24 nit: this could be of the format var TaskSchedule
robliao 2016/11/08 18:14:18 Done.
6
Dan Beam 2016/10/29 01:13:24 can we get a little more specific? /** @typedef {
robliao 2016/11/08 18:14:18 Done.
7 /**
8 * Updates the histograms on the page.
9 * @param {Array<Object>} histograms Array of histogram objects.
Dan Beam 2016/10/29 01:13:24 nit: !Array<!Histogram>
robliao 2016/11/08 18:14:18 Done.
10 */
11 TaskSchedulerInternals.updateHistograms = function(histograms) {
12 var histogramContainer = $('histogram-container');
13 for (var i in histograms) {
14 var histogram = histograms[i];
15 var title = document.createElement('div');
16 title.innerHTML = histogram.name;
xiyuan 2016/10/19 17:49:57 nit: title.textContent = histogram.name; avoid us
robliao 2016/10/19 21:24:28 Done.
Dan Beam 2016/10/29 01:13:24 all of these .innerHTML setters could actually use
robliao 2016/11/08 18:14:18 On trunk: textContent was used at commit time.
17 histogramContainer.appendChild(title);
18 if (histogram.buckets.length > 0) {
19 histogramContainer.appendChild(
20 TaskSchedulerInternals.createHistogramTable(histogram.buckets));
21 } else {
22 var unavailable = document.createElement('div');
23 unavailable.innerHTML = 'No Data Recorded';
xiyuan 2016/10/19 17:49:57 nit: .innerHTML -> .textContent
robliao 2016/10/19 21:24:28 Done.
24 histogramContainer.appendChild(unavailable);
25 }
26 }
27 };
28
29 /**
30 * Returns a table representation of the histogram buckets.
31 * @param {Object} buckets The histogram buckets.
32 * @return {Object} A table element representation of the histogram buckets.
33 */
34 TaskSchedulerInternals.createHistogramTable = function(buckets) {
35 var table = document.createElement('table');
36 var headerRow = document.createElement('tr');
37 var dataRow = document.createElement('tr');
38 for (var i in buckets) {
39 var bucket = buckets[i];
40 var header = document.createElement('th');
41 header.innerHTML = bucket.min + '-' + bucket.max;
xiyuan 2016/10/19 17:49:57 nit: .innerHTML -> .textContent
robliao 2016/10/19 21:24:28 Done.
Dan Beam 2016/10/29 01:13:24 btw, we can now use `template replacements`, so th
robliao 2016/11/08 18:14:18 Done.
42 headerRow.appendChild(header);
43 var data = document.createElement('td');
44 data.innerHTML = bucket.count;
xiyuan 2016/10/19 17:49:57 nit: .innerHTML -> .textContent
robliao 2016/10/19 21:24:28 Done.
45 dataRow.appendChild(data);
46 }
47 table.appendChild(headerRow);
48 table.appendChild(dataRow);
49 return table;
50 };
51
52 /**
53 * Handles callback from onGetTaskSchedulerData.
54 * @param {Object} data Dictionary containing all task scheduler metrics.
55 */
56 TaskSchedulerInternals.onGetTaskSchedulerData = function(data) {
57 $('status').innerHTML =
xiyuan 2016/10/19 17:49:57 nit: .innerHTML -> .textContent
robliao 2016/10/19 21:24:28 Done.
58 data.instantiated ? 'Instantiated' : 'Not Instantiated';
59 $('details').style.visibility = data.instantiated ? 'visible' : 'hidden';
Dan Beam 2016/10/29 01:13:24 $('details').hidden = !data.instantiated;
robliao 2016/11/08 18:14:18 On trunk: This was done at commit time.
60 if (!data.instantiated)
61 return;
62
63 TaskSchedulerInternals.updateHistograms(data.histograms);
64 };
65
66 document.addEventListener('DOMContentLoaded', function() {
67 chrome.send('getTaskSchedulerData');
68 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698