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

Side by Side Diff: chrome/browser/resources/chromeos/power.js

Issue 917093003: Shorten Closure template notation from Array.<*> to Array<*>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove cvox Created 5 years, 10 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 * Plot a line graph of data versus time on a HTML canvas element. 6 * Plot a line graph of data versus time on a HTML canvas element.
7 * 7 *
8 * @param {HTMLCanvasElement} plotCanvas The canvas on which the line graph is 8 * @param {HTMLCanvasElement} plotCanvas The canvas on which the line graph is
9 * drawn. 9 * drawn.
10 * @param {HTMLCanvasElement} legendCanvas The canvas on which the legend for 10 * @param {HTMLCanvasElement} legendCanvas The canvas on which the legend for
11 * the line graph is drawn. 11 * the line graph is drawn.
12 * @param {Array.<number>} tData The time (in seconds) in the past when the 12 * @param {Array<number>} tData The time (in seconds) in the past when the
13 * corresponding data in plots was sampled. 13 * corresponding data in plots was sampled.
14 * @param {Array.<{data: Array.<number>, color: string}>} plots An 14 * @param {Array<{data: Array<number>, color: string}>} plots An
15 * array of plots to plot on the canvas. The field 'data' of a plot is an 15 * array of plots to plot on the canvas. The field 'data' of a plot is an
16 * array of samples to be plotted as a line graph with color speficied by 16 * array of samples to be plotted as a line graph with color speficied by
17 * the field 'color'. The elements in the 'data' array are ordered 17 * the field 'color'. The elements in the 'data' array are ordered
18 * corresponding to their sampling time in the argument 'tData'. Also, the 18 * corresponding to their sampling time in the argument 'tData'. Also, the
19 * number of elements in the 'data' array should be the same as in the time 19 * number of elements in the 'data' array should be the same as in the time
20 * array 'tData' above. 20 * array 'tData' above.
21 * @param {number} yMin Minimum bound of y-axis 21 * @param {number} yMin Minimum bound of y-axis
22 * @param {number} yMax Maximum bound of y-axis. 22 * @param {number} yMax Maximum bound of y-axis.
23 * @param {integer} yPrecision An integer value representing the number of 23 * @param {integer} yPrecision An integer value representing the number of
24 * digits of precision the y-axis data should be printed with. 24 * digits of precision the y-axis data should be printed with.
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 var invalidDataText = loadTimeData.getString('invalidData'); 390 var invalidDataText = loadTimeData.getString('invalidData');
391 var offlineText = loadTimeData.getString('offlineText'); 391 var offlineText = loadTimeData.getString('offlineText');
392 392
393 var plotColors = ['Red', 'Blue', 'Green', 'Gold', 'CadetBlue', 'LightCoral', 393 var plotColors = ['Red', 'Blue', 'Green', 'Gold', 'CadetBlue', 'LightCoral',
394 'LightSlateGray', 'Peru', 'DarkRed', 'LawnGreen', 'Tan']; 394 'LightSlateGray', 'Peru', 'DarkRed', 'LawnGreen', 'Tan'];
395 395
396 /** 396 /**
397 * Add canvases for plotting to |plotsDiv|. For every header in |headerArray|, 397 * Add canvases for plotting to |plotsDiv|. For every header in |headerArray|,
398 * one canvas for the plot and one for its legend are added. 398 * one canvas for the plot and one for its legend are added.
399 * 399 *
400 * @param {Array.<string>} headerArray Headers for the different plots to be 400 * @param {Array<string>} headerArray Headers for the different plots to be
401 * added to |plotsDiv|. 401 * added to |plotsDiv|.
402 * @param {HTMLDivElement} plotsDiv The div element into which the canvases 402 * @param {HTMLDivElement} plotsDiv The div element into which the canvases
403 * are added. 403 * are added.
404 * @return {<string>: {plotCanvas: <HTMLCanvasElement>, 404 * @return {<string>: {plotCanvas: <HTMLCanvasElement>,
405 * legendCanvas: <HTMLCanvasElement>} Returns an object 405 * legendCanvas: <HTMLCanvasElement>} Returns an object
406 * with the headers as 'keys'. Each element is an object containing the 406 * with the headers as 'keys'. Each element is an object containing the
407 * legend canvas and the plot canvas that have been added to |plotsDiv|. 407 * legend canvas and the plot canvas that have been added to |plotsDiv|.
408 */ 408 */
409 function addCanvases(headerArray, plotsDiv) { 409 function addCanvases(headerArray, plotsDiv) {
410 // Remove the contents before adding new ones. 410 // Remove the contents before adding new ones.
(...skipping 25 matching lines...) Expand all
436 canvases[headerArray[i]] = {plot: plotCanvas, legend: legendCanvas}; 436 canvases[headerArray[i]] = {plot: plotCanvas, legend: legendCanvas};
437 } 437 }
438 return canvases; 438 return canvases;
439 } 439 }
440 440
441 /** 441 /**
442 * Add samples in |sampleArray| to individual plots in |plots|. If the system 442 * Add samples in |sampleArray| to individual plots in |plots|. If the system
443 * resumed from a sleep/suspend, then "suspended" sleep samples are added to 443 * resumed from a sleep/suspend, then "suspended" sleep samples are added to
444 * the plot for the sleep duration. 444 * the plot for the sleep duration.
445 * 445 *
446 * @param {Array.<{data: Array.<number>, color: string}>} plots An 446 * @param {Array<{data: Array<number>, color: string}>} plots An
447 * array of plots to plot on the canvas. The field 'data' of a plot is an 447 * array of plots to plot on the canvas. The field 'data' of a plot is an
448 * array of samples to be plotted as a line graph with color speficied by 448 * array of samples to be plotted as a line graph with color speficied by
449 * the field 'color'. The elements in the 'data' array are ordered 449 * the field 'color'. The elements in the 'data' array are ordered
450 * corresponding to their sampling time in the argument 'tData'. Also, the 450 * corresponding to their sampling time in the argument 'tData'. Also, the
451 * number of elements in the 'data' array should be the same as in the time 451 * number of elements in the 'data' array should be the same as in the time
452 * array 'tData' below. 452 * array 'tData' below.
453 * @param {Array.<number>} tData The time (in seconds) in the past when the 453 * @param {Array<number>} tData The time (in seconds) in the past when the
454 * corresponding data in plots was sampled. 454 * corresponding data in plots was sampled.
455 * @param {Array.<number>} sampleArray The array of samples wherein each 455 * @param {Array<number>} absTime
456 * @param {Array<number>} sampleArray The array of samples wherein each
456 * element corresponds to the individual plot in |plots|. 457 * element corresponds to the individual plot in |plots|.
457 * @param {number} sampleTime Time in milliseconds since the epoch when the 458 * @param {number} sampleTime Time in milliseconds since the epoch when the
458 * samples in |sampleArray| were captured. 459 * samples in |sampleArray| were captured.
459 * @param {number} previousSampleTime Time in milliseconds since the epoch 460 * @param {number} previousSampleTime Time in milliseconds since the epoch
460 * when the sample prior to the current sample was captured. 461 * when the sample prior to the current sample was captured.
461 * @param {Array.<{time: number, sleepDuration: number}>} systemResumedArray An 462 * @param {Array<{time: number, sleepDuration: number}>} systemResumedArray An
462 * array objects corresponding to system resume events. The 'time' field is 463 * array objects corresponding to system resume events. The 'time' field is
463 * for the time in milliseconds since the epoch when the system resumed. The 464 * for the time in milliseconds since the epoch when the system resumed. The
464 * 'sleepDuration' field is for the time in milliseconds the system spent 465 * 'sleepDuration' field is for the time in milliseconds the system spent
465 * in sleep/suspend state. 466 * in sleep/suspend state.
466 */ 467 */
467 function addTimeDataSample(plots, tData, absTime, sampleArray, 468 function addTimeDataSample(plots, tData, absTime, sampleArray,
468 sampleTime, previousSampleTime, 469 sampleTime, previousSampleTime,
469 systemResumedArray) { 470 systemResumedArray) {
470 for (var i = 0; i < plots.length; i++) { 471 for (var i = 0; i < plots.length; i++) {
471 if (plots[i].data.length != tData.length) { 472 if (plots[i].data.length != tData.length) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 absTime.push(sampleTime); 513 absTime.push(sampleTime);
513 tData.push(time.toLocaleTimeString()); 514 tData.push(time.toLocaleTimeString());
514 for (var i = 0; i < plots.length; i++) { 515 for (var i = 0; i < plots.length; i++) {
515 plots[i].data.push(sampleArray[i]); 516 plots[i].data.push(sampleArray[i]);
516 } 517 }
517 } 518 }
518 519
519 /** 520 /**
520 * Display the battery charge vs time on a line graph. 521 * Display the battery charge vs time on a line graph.
521 * 522 *
522 * @param {Array.<{time: number, 523 * @param {Array<{time: number,
523 * batteryPercent: number, 524 * batteryPercent: number,
524 * batteryDischargeRate: number, 525 * batteryDischargeRate: number,
525 * externalPower: number}>} powerSupplyArray An array of objects 526 * externalPower: number}>} powerSupplyArray An array of objects
526 * with fields representing the battery charge, time when the charge 527 * with fields representing the battery charge, time when the charge
527 * measurement was taken, and whether there was external power connected at 528 * measurement was taken, and whether there was external power connected at
528 * that time. 529 * that time.
529 * @param {Array.<{time: ?, sleepDuration: ?}>} systemResumedArray An array 530 * @param {Array<{time: ?, sleepDuration: ?}>} systemResumedArray An array
530 * objects with fields 'time' and 'sleepDuration'. Each object corresponds 531 * objects with fields 'time' and 'sleepDuration'. Each object corresponds
531 * to a system resume event. The 'time' field is for the time in 532 * to a system resume event. The 'time' field is for the time in
532 * milliseconds since the epoch when the system resumed. The 'sleepDuration' 533 * milliseconds since the epoch when the system resumed. The 'sleepDuration'
533 * field is for the time in milliseconds the system spent in sleep/suspend 534 * field is for the time in milliseconds the system spent in sleep/suspend
534 * state. 535 * state.
535 */ 536 */
536 function showBatteryChargeData(powerSupplyArray, systemResumedArray) { 537 function showBatteryChargeData(powerSupplyArray, systemResumedArray) {
537 var chargeTimeData = []; 538 var chargeTimeData = [];
538 var chargeAbsTime = []; 539 var chargeAbsTime = [];
539 var chargePlot = [ 540 var chargePlot = [
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 dischargeRatePlot, 643 dischargeRatePlot,
643 minDischargeRate, 644 minDischargeRate,
644 maxDischargeRate, 645 maxDischargeRate,
645 3); 646 3);
646 } 647 }
647 648
648 /** 649 /**
649 * Shows state occupancy data (CPU idle or CPU freq state occupancy) on a set of 650 * Shows state occupancy data (CPU idle or CPU freq state occupancy) on a set of
650 * plots on the about:power UI. 651 * plots on the about:power UI.
651 * 652 *
652 * @param {Array.<{Array.<{ 653 * @param {Array<Array<{
653 * time: number, 654 * time: number,
654 * cpuOnline:boolean, 655 * cpuOnline: boolean,
655 * timeInState: {<string>: number}>}>} timeInStateData Array of arrays 656 * timeInState: Object<number>}>} timeInStateData Array of arrays
656 * where each array corresponds to a CPU on the system. The elements of the 657 * where each array corresponds to a CPU on the system. The elements of the
657 * individual arrays contain state occupancy samples. 658 * individual arrays contain state occupancy samples.
658 * @param {Array.<{time: ?, sleepDuration: ?}>} systemResumedArray An array 659 * @param {Array<{time: ?, sleepDuration: ?}>} systemResumedArray An array
659 * objects with fields 'time' and 'sleepDuration'. Each object corresponds 660 * objects with fields 'time' and 'sleepDuration'. Each object corresponds
660 * to a system resume event. The 'time' field is for the time in 661 * to a system resume event. The 'time' field is for the time in
661 * milliseconds since the epoch when the system resumed. The 'sleepDuration' 662 * milliseconds since the epoch when the system resumed. The 'sleepDuration'
662 * field is for the time in milliseconds the system spent in sleep/suspend 663 * field is for the time in milliseconds the system spent in sleep/suspend
663 * state. 664 * state.
664 * @param {string} i18nHeaderString The header string to be displayed with each 665 * @param {string} i18nHeaderString The header string to be displayed with each
665 * plot. For example, CPU idle data will have its own header format, and CPU 666 * plot. For example, CPU idle data will have its own header format, and CPU
666 * freq data will have its header format. 667 * freq data will have its header format.
667 * @param {string} unitString This is the string capturing the unit, if any, 668 * @param {string} unitString This is the string capturing the unit, if any,
668 * for the different states. Note that this is not the unit of the data 669 * for the different states. Note that this is not the unit of the data
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 $('cpu-idle-section').hidden = true; 857 $('cpu-idle-section').hidden = true;
857 $('cpu-idle-show-button').onclick = showHideCallback( 858 $('cpu-idle-show-button').onclick = showHideCallback(
858 'cpu-idle-section', 'cpu-idle-show-button', requestCpuIdleData); 859 'cpu-idle-section', 'cpu-idle-show-button', requestCpuIdleData);
859 $('cpu-idle-reload-button').onclick = requestCpuIdleData; 860 $('cpu-idle-reload-button').onclick = requestCpuIdleData;
860 861
861 $('cpu-freq-section').hidden = true; 862 $('cpu-freq-section').hidden = true;
862 $('cpu-freq-show-button').onclick = showHideCallback( 863 $('cpu-freq-show-button').onclick = showHideCallback(
863 'cpu-freq-section', 'cpu-freq-show-button', requestCpuFreqData); 864 'cpu-freq-section', 'cpu-freq-show-button', requestCpuFreqData);
864 $('cpu-freq-reload-button').onclick = requestCpuFreqData; 865 $('cpu-freq-reload-button').onclick = requestCpuFreqData;
865 }); 866 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698