| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @fileoverview Utility methods for accessing chrome.metricsPrivate API. | 6 * @fileoverview Utility methods for accessing chrome.metricsPrivate API. |
| 7 * | 7 * |
| 8 * To be included as a first script in main.html | 8 * To be included as a first script in main.html |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 var metrics = {}; | 11 var metrics = {}; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * A map from interval name to interval start timestamp. | 14 * A map from interval name to interval start timestamp. |
| 15 */ | 15 */ |
| 16 metrics.intervals = {}; | 16 metrics.intervals = {}; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Start the named time interval. | 19 * Start the named time interval. |
| 20 * Should be followed by a call to recordInterval with the same name. | 20 * Should be followed by a call to recordInterval with the same name. |
| 21 * | 21 * |
| 22 * @param {string} name Unique interval name. | 22 * @param {string} name Unique interval name. |
| 23 */ | 23 */ |
| 24 metrics.startInterval = function(name) { | 24 metrics.startInterval = function(name) { |
| 25 metrics.intervals[name] = Date.now(); | 25 metrics.intervals[name] = Date.now(); |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 metrics.startInterval('Load.Total'); | 28 metrics.startInterval('Load.Total'); |
| 29 metrics.startInterval('Load.Script'); | 29 metrics.startInterval('Load.Script'); |
| 30 metrics.startInterval('Load.Display'); |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * Convert a short metric name to the full format. | 33 * Convert a short metric name to the full format. |
| 33 * | 34 * |
| 34 * @param {string} name Short metric name. | 35 * @param {string} name Short metric name. |
| 35 * @return {string} Full metric name. | 36 * @return {string} Full metric name. |
| 36 * @private | 37 * @private |
| 37 */ | 38 */ |
| 38 metrics.convertName_ = function(name) { | 39 metrics.convertName_ = function(name) { |
| 39 return 'FileBrowser.' + name; | 40 return 'FileBrowser.' + name; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 'min': 1, | 123 'min': 1, |
| 123 'max': boundaryValue, | 124 'max': boundaryValue, |
| 124 'buckets': boundaryValue + 1 | 125 'buckets': boundaryValue + 1 |
| 125 }; | 126 }; |
| 126 metrics.call_('recordValue', [metricDescr, index]); | 127 metrics.call_('recordValue', [metricDescr, index]); |
| 127 if (metrics.log) { | 128 if (metrics.log) { |
| 128 console.log('chrome.metricsPrivate.recordValue', | 129 console.log('chrome.metricsPrivate.recordValue', |
| 129 [metricDescr.metricName, index, value]); | 130 [metricDescr.metricName, index, value]); |
| 130 } | 131 } |
| 131 }; | 132 }; |
| OLD | NEW |