| Index: chrome/browser/resources/file_manager/js/metrics.js
|
| diff --git a/chrome/browser/resources/file_manager/js/metrics.js b/chrome/browser/resources/file_manager/js/metrics.js
|
| index 5daff8a520a494655e0557f748dd8d3296fd5624..90be746aac03aaeb8cad725d728ee74621ef75fd 100644
|
| --- a/chrome/browser/resources/file_manager/js/metrics.js
|
| +++ b/chrome/browser/resources/file_manager/js/metrics.js
|
| @@ -23,36 +23,54 @@ metrics.convertName_ = function(name) {
|
| return 'FileBrowser.' + name;
|
| };
|
|
|
| -metrics.recordTime = function(name) {
|
| - if (name in metrics.intervals) {
|
| - var elapsed = Date.now() - metrics.intervals[name];
|
| - console.log(name + ': ' + elapsed + 'ms');
|
| - chrome.metricsPrivate.recordTime(metrics.convertName_(name), elapsed);
|
| - } else {
|
| - console.error('Unknown interval: ' + name);
|
| +metrics.decorate = function(name) {
|
| + this[name] = function() {
|
| + var args = Array.apply(null, arguments);
|
| + args[0] = metrics.convertName_(args[0]);
|
| + chrome.metricsPrivate[name].apply(chrome.metricsPrivate, args);
|
| + if (localStorage.logMetrics) {
|
| + console.log('chrome.metricsPrivate.' + name, args);
|
| + }
|
| }
|
| };
|
|
|
| -metrics.recordAction = function(name) {
|
| - chrome.metricsPrivate.recordUserAction(metrics.convertName_(name));
|
| -};
|
| +metrics.decorate('recordMediumCount');
|
| +metrics.decorate('recordSmallCount');
|
| +metrics.decorate('recordTime');
|
| +metrics.decorate('recordUserAction');
|
|
|
| -metrics.reportCount = function(name, value) {
|
| - chrome.metricsPrivate.recordMediumCount(metrics.convertName_(name), value);
|
| +metrics.recordInterval = function(name) {
|
| + if (name in metrics.intervals) {
|
| + metrics.recordTime(name, Date.now() - metrics.intervals[name]);
|
| + } else {
|
| + console.error('Unknown interval: ' + name);
|
| + }
|
| };
|
|
|
| metrics.recordEnum = function(name, value, validValues) {
|
| - var index = validValues.indexOf(value);
|
| -
|
| + var maxValue;
|
| + var index;
|
| + if (validValues.constructor.name == 'Array') {
|
| + index = validValues.indexOf(value);
|
| + maxValue = validValues.length - 1;
|
| + } else {
|
| + index = value;
|
| + maxValue = validValues - 1;
|
| + }
|
| // Collect invalid values in the extra bucket at the end.
|
| - if (index < 0) index = validValues.length;
|
| -
|
| - chrome.metricsPrivate.recordValue({
|
| - 'metricName': metrics.convertName_(name),
|
| - 'type': 'histogram-linear',
|
| - 'min': 0,
|
| - 'max': validValues.length,
|
| - 'buckets': validValues.length + 1
|
| - },
|
| - index);
|
| + if (index < 0 || index > maxValue)
|
| + index = maxValue;
|
| +
|
| + var metricDescr = {
|
| + 'metricName': metrics.convertName_(name),
|
| + 'type': 'histogram-linear',
|
| + 'min': 0,
|
| + 'max': maxValue,
|
| + 'buckets': maxValue + 1
|
| + };
|
| + chrome.metricsPrivate.recordValue(metricDescr, index);
|
| + if (localStorage.logMetrics) {
|
| + console.log('chrome.metricsPrivate.recordValue',
|
| + [metricDescr.metricName, index, value]);
|
| + }
|
| };
|
|
|