| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.experimental.metrics API. | 6 * @fileoverview Utility methods for accessing chrome.experimental.metrics 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 var elapsed = Date.now() - metrics.intervals[name]; | 29 var elapsed = Date.now() - metrics.intervals[name]; |
| 30 console.log(name + ': ' + elapsed + 'ms'); | 30 console.log(name + ': ' + elapsed + 'ms'); |
| 31 chrome.experimental.metrics.recordTime(metrics.convertName_(name), elapsed); | 31 chrome.experimental.metrics.recordTime(metrics.convertName_(name), elapsed); |
| 32 } else { | 32 } else { |
| 33 console.error('Unknown interval: ' + name); | 33 console.error('Unknown interval: ' + name); |
| 34 } | 34 } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 metrics.recordAction = function(name) { | 37 metrics.recordAction = function(name) { |
| 38 chrome.experimental.metrics.recordUserAction(metrics.convertName_(name)); | 38 chrome.experimental.metrics.recordUserAction(metrics.convertName_(name)); |
| 39 }; | 39 }; |
| 40 |
| 41 metrics.reportCount = function(name, value) { |
| 42 chrome.experimental.metrics. |
| 43 recordMediumCount(metrics.convertName_(name), value); |
| 44 }; |
| 45 |
| 46 metrics.recordEnum = function(name, value, validValues) { |
| 47 var index = validValues.indexOf(value); |
| 48 |
| 49 // Collect invalid values in the extra bucket at the end. |
| 50 if (index < 0) index = validValues.length; |
| 51 |
| 52 chrome.experimental.metrics.recordValue({ |
| 53 'metricName': metrics.convertName_(name), |
| 54 'type': 'histogram-linear', |
| 55 'min': 0, |
| 56 'max': validValues.length, |
| 57 'buckets': validValues.length + 1 |
| 58 }, |
| 59 index); |
| 60 }; |
| OLD | NEW |