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

Unified Diff: chrome/browser/resources/task_scheduler_internals/index.js

Issue 2484043004: Apply Delayed Code Review Comments to Task Scheduler Internals (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/task_scheduler_internals/index.js
diff --git a/chrome/browser/resources/task_scheduler_internals/index.js b/chrome/browser/resources/task_scheduler_internals/index.js
index 72006c59a33b29e9cf3a87f9ca410ab0c5a51f65..87da676411d56d07f0cdc6f938ec7f612789ad0b 100644
--- a/chrome/browser/resources/task_scheduler_internals/index.js
+++ b/chrome/browser/resources/task_scheduler_internals/index.js
@@ -2,65 +2,71 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var TaskSchedulerInternals = {};
+/** @typedef {{min: number, max: number, count: number}} */
+var Bucket;
-/**
- * Updates the histograms on the page.
- * @param {Array<Object>} histograms Array of histogram objects.
- */
-TaskSchedulerInternals.updateHistograms = function(histograms) {
- var histogramContainer = $('histogram-container');
- for (var i in histograms) {
- var histogram = histograms[i];
- var title = document.createElement('div');
- title.textContent = histogram.name;
- histogramContainer.appendChild(title);
- if (histogram.buckets.length > 0) {
- histogramContainer.appendChild(
- TaskSchedulerInternals.createHistogramTable(histogram.buckets));
- } else {
- var unavailable = document.createElement('div');
- unavailable.textContent = 'No Data Recorded';
- histogramContainer.appendChild(unavailable);
+/** @typedef {{name: string, buckets: !Array<Bucket>}} */
+var Histogram;
+
+var TaskSchedulerInternals = {
+ /**
+ * Updates the histograms on the page.
+ * @param {!Array<!Histogram>} histograms Array of histogram objects.
+ */
+ updateHistograms: function(histograms) {
+ var histogramContainer = $('histogram-container');
+ for (var i in histograms) {
+ var histogram = histograms[i];
+ var title = document.createElement('div');
+ title.textContent = histogram.name;
+ histogramContainer.appendChild(title);
+ if (histogram.buckets.length > 0) {
+ histogramContainer.appendChild(
+ TaskSchedulerInternals.createHistogramTable(histogram.buckets));
+ } else {
+ var unavailable = document.createElement('div');
+ unavailable.textContent = 'No Data Recorded';
+ histogramContainer.appendChild(unavailable);
+ }
}
- }
-};
+ },
-/**
- * Returns a table representation of the histogram buckets.
- * @param {Object} buckets The histogram buckets.
- * @return {Object} A table element representation of the histogram buckets.
- */
-TaskSchedulerInternals.createHistogramTable = function(buckets) {
- var table = document.createElement('table');
- var headerRow = document.createElement('tr');
- var dataRow = document.createElement('tr');
- for (var i in buckets) {
- var bucket = buckets[i];
- var header = document.createElement('th');
- header.textContent = bucket.min + '-' + bucket.max;
- headerRow.appendChild(header);
- var data = document.createElement('td');
- data.textContent = bucket.count;
- dataRow.appendChild(data);
- }
- table.appendChild(headerRow);
- table.appendChild(dataRow);
- return table;
-};
+ /**
+ * Returns a table representation of the histogram buckets.
+ * @param {Object} buckets The histogram buckets.
+ * @return {Object} A table element representation of the histogram buckets.
+ */
+ createHistogramTable: function(buckets) {
+ var table = document.createElement('table');
+ var headerRow = document.createElement('tr');
+ var dataRow = document.createElement('tr');
+ for (var i in buckets) {
+ var bucket = buckets[i];
+ var header = document.createElement('th');
+ header.textContent = `${bucket.min}-${bucket.max}`;
+ headerRow.appendChild(header);
+ var data = document.createElement('td');
+ data.textContent = bucket.count;
+ dataRow.appendChild(data);
+ }
+ table.appendChild(headerRow);
+ table.appendChild(dataRow);
+ return table;
+ },
-/**
- * Handles callback from onGetTaskSchedulerData.
- * @param {Object} data Dictionary containing all task scheduler metrics.
- */
-TaskSchedulerInternals.onGetTaskSchedulerData = function(data) {
- $('status').textContent =
- data.instantiated ? 'Instantiated' : 'Not Instantiated';
- $('details').hidden = !data.instantiated;
- if (!data.instantiated)
- return;
+ /**
+ * Handles callback from onGetTaskSchedulerData.
+ * @param {Object} data Dictionary containing all task scheduler metrics.
+ */
+ onGetTaskSchedulerData: function(data) {
+ $('status').textContent =
+ data.instantiated ? 'Instantiated' : 'Not Instantiated';
+ $('details').hidden = !data.instantiated;
+ if (!data.instantiated)
+ return;
- TaskSchedulerInternals.updateHistograms(data.histograms);
+ TaskSchedulerInternals.updateHistograms(data.histograms);
+ }
};
document.addEventListener('DOMContentLoaded', function() {
« no previous file with comments | « no previous file | chrome/browser/ui/webui/task_scheduler_internals/task_scheduler_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698