| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 * @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 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Collect invalid values in the overflow bucket at the end. | 154 // Collect invalid values in the overflow bucket at the end. |
| 155 if (index < 0 || index >= boundaryValue) | 155 if (index < 0 || index >= boundaryValue) |
| 156 index = boundaryValue - 1; | 156 index = boundaryValue - 1; |
| 157 | 157 |
| 158 // Setting min to 1 looks strange but this is exactly the recommended way | 158 // Setting min to 1 looks strange but this is exactly the recommended way |
| 159 // of using histograms for enum-like types. Bucket #0 works as a regular | 159 // of using histograms for enum-like types. Bucket #0 works as a regular |
| 160 // bucket AND the underflow bucket. | 160 // bucket AND the underflow bucket. |
| 161 // (Source: UMA_HISTOGRAM_ENUMERATION definition in base/metrics/histogram.h) | 161 // (Source: UMA_HISTOGRAM_ENUMERATION definition in base/metrics/histogram.h) |
| 162 var metricDescr = { | 162 var metricDescr = { |
| 163 'metricName': metrics.convertName_(name), | 163 'metricName': metrics.convertName_(name), |
| 164 'type': 'histogram-linear', | 164 'type': chrome.metricsPrivate.MetricTypeType.HISTOGRAM_LINEAR, |
| 165 'min': 1, | 165 'min': 1, |
| 166 'max': boundaryValue, | 166 'max': boundaryValue, |
| 167 'buckets': boundaryValue | 167 'buckets': boundaryValue |
| 168 }; | 168 }; |
| 169 metrics.call_('recordValue', [metricDescr, index]); | 169 metrics.call_('recordValue', [metricDescr, index]); |
| 170 }; | 170 }; |
| OLD | NEW |