| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Object used to measure usage statistics. | 9 * Object used to measure usage statistics. |
| 10 * @constructor | 10 * @constructor |
| 11 */ | 11 */ |
| 12 function Metrics() {}; | 12 function Metrics(){}; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Enumeration of buckets that a user can enter while using the destination | 15 * Enumeration of buckets that a user can enter while using the destination |
| 16 * search widget. | 16 * search widget. |
| 17 * @enum {number} | 17 * @enum {number} |
| 18 */ | 18 */ |
| 19 Metrics.DestinationSearchBucket = { | 19 Metrics.DestinationSearchBucket = { |
| 20 // Used when the print destination search widget is shown. | 20 // Used when the print destination search widget is shown. |
| 21 DESTINATION_SHOWN: 0, | 21 DESTINATION_SHOWN: 0, |
| 22 // Used when the user selects a print destination. | 22 // Used when the user selects a print destination. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 this.maxBucket_ = maxBucket; | 107 this.maxBucket_ = maxBucket; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 MetricsContext.prototype = { | 110 MetricsContext.prototype = { |
| 111 /** | 111 /** |
| 112 * Record a histogram value in UMA. If specified value is larger than the | 112 * Record a histogram value in UMA. If specified value is larger than the |
| 113 * max bucket value, record the value in the largest bucket | 113 * max bucket value, record the value in the largest bucket |
| 114 * @param {number} bucket Value to record. | 114 * @param {number} bucket Value to record. |
| 115 */ | 115 */ |
| 116 record: function(bucket) { | 116 record: function(bucket) { |
| 117 chrome.send('metricsHandler:recordInHistogram', | 117 chrome.send('metricsHandler:recordInHistogram', [ |
| 118 [this.histogram_, | 118 this.histogram_, |
| 119 ((bucket > this.maxBucket_) ? this.maxBucket_ : bucket), | 119 ((bucket > this.maxBucket_) ? this.maxBucket_ : bucket), this.maxBucket_ |
| 120 this.maxBucket_]); | 120 ]); |
| 121 } | 121 } |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Destination Search specific usage statistics context. | 125 * Destination Search specific usage statistics context. |
| 126 * @constructor | 126 * @constructor |
| 127 * @extends {print_preview.MetricsContext} | 127 * @extends {print_preview.MetricsContext} |
| 128 */ | 128 */ |
| 129 function DestinationSearchMetricsContext() { | 129 function DestinationSearchMetricsContext() { |
| 130 MetricsContext.call( | 130 MetricsContext.call( |
| 131 this, | 131 this, 'PrintPreview.DestinationAction', |
| 132 'PrintPreview.DestinationAction', | |
| 133 Metrics.DestinationSearchBucket.DESTINATION_SEARCH_MAX_BUCKET); | 132 Metrics.DestinationSearchBucket.DESTINATION_SEARCH_MAX_BUCKET); |
| 134 }; | 133 }; |
| 135 | 134 |
| 136 DestinationSearchMetricsContext.prototype = { | 135 DestinationSearchMetricsContext.prototype = { |
| 137 __proto__: MetricsContext.prototype | 136 __proto__: MetricsContext.prototype |
| 138 }; | 137 }; |
| 139 | 138 |
| 140 /** | 139 /** |
| 141 * GCP promotion specific usage statistics context. | 140 * GCP promotion specific usage statistics context. |
| 142 * @constructor | 141 * @constructor |
| 143 * @extends {print_preview.MetricsContext} | 142 * @extends {print_preview.MetricsContext} |
| 144 */ | 143 */ |
| 145 function GcpPromoMetricsContext() { | 144 function GcpPromoMetricsContext() { |
| 146 MetricsContext.call(this, | 145 MetricsContext.call( |
| 147 'PrintPreview.GcpPromo', | 146 this, 'PrintPreview.GcpPromo', |
| 148 Metrics.GcpPromoBucket.GCP_PROMO_MAX_BUCKET); | 147 Metrics.GcpPromoBucket.GCP_PROMO_MAX_BUCKET); |
| 149 }; | 148 }; |
| 150 | 149 |
| 151 GcpPromoMetricsContext.prototype = { | 150 GcpPromoMetricsContext.prototype = {__proto__: MetricsContext.prototype}; |
| 152 __proto__: MetricsContext.prototype | |
| 153 }; | |
| 154 | 151 |
| 155 /** | 152 /** |
| 156 * Print settings UI specific usage statistics context. | 153 * Print settings UI specific usage statistics context. |
| 157 * @constructor | 154 * @constructor |
| 158 * @extends {print_preview.MetricsContext} | 155 * @extends {print_preview.MetricsContext} |
| 159 */ | 156 */ |
| 160 function PrintSettingsUiMetricsContext() { | 157 function PrintSettingsUiMetricsContext() { |
| 161 MetricsContext.call( | 158 MetricsContext.call( |
| 162 this, | 159 this, 'PrintPreview.PrintSettingsUi', |
| 163 'PrintPreview.PrintSettingsUi', | |
| 164 Metrics.PrintSettingsUiBucket.PRINT_SETTINGS_UI_MAX_BUCKET); | 160 Metrics.PrintSettingsUiBucket.PRINT_SETTINGS_UI_MAX_BUCKET); |
| 165 }; | 161 }; |
| 166 | 162 |
| 167 PrintSettingsUiMetricsContext.prototype = { | 163 PrintSettingsUiMetricsContext.prototype = { |
| 168 __proto__: MetricsContext.prototype | 164 __proto__: MetricsContext.prototype |
| 169 }; | 165 }; |
| 170 | 166 |
| 171 // Export | 167 // Export |
| 172 return { | 168 return { |
| 173 Metrics: Metrics, | 169 Metrics: Metrics, |
| 174 MetricsContext: MetricsContext, | 170 MetricsContext: MetricsContext, |
| 175 DestinationSearchMetricsContext: DestinationSearchMetricsContext, | 171 DestinationSearchMetricsContext: DestinationSearchMetricsContext, |
| 176 GcpPromoMetricsContext: GcpPromoMetricsContext, | 172 GcpPromoMetricsContext: GcpPromoMetricsContext, |
| 177 PrintSettingsUiMetricsContext: PrintSettingsUiMetricsContext | 173 PrintSettingsUiMetricsContext: PrintSettingsUiMetricsContext |
| 178 }; | 174 }; |
| 179 }); | 175 }); |
| OLD | NEW |