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 | 6 * @fileoverview |
7 * The webapp reads the plugin's connection statistics frequently (once per | 7 * The webapp reads the plugin's connection statistics frequently (once per |
8 * second). It logs statistics to the server less frequently, to keep | 8 * second). It logs statistics to the server less frequently, to keep |
9 * bandwidth and storage costs down. This class bridges that gap, by | 9 * bandwidth and storage costs down. This class bridges that gap, by |
10 * accumulating high-frequency numeric data, and providing statistics | 10 * accumulating high-frequency numeric data, and providing statistics |
11 * summarising that data. | 11 * summarising that data. |
12 */ | 12 */ |
13 | 13 |
14 'use strict'; | 14 'use strict'; |
15 | 15 |
16 /** @suppress {duplicate} */ | 16 /** @suppress {duplicate} */ |
17 var remoting = remoting || {}; | 17 var remoting = remoting || {}; |
18 | 18 |
19 /** | 19 /** |
20 * @constructor | 20 * @constructor |
21 */ | 21 */ |
22 remoting.StatsAccumulator = function() { | 22 remoting.StatsAccumulator = function() { |
23 /** | 23 /** |
24 * A map from names to lists of values. | 24 * A map from names to lists of values. |
25 * @private | 25 * @private {Object<string, Array<number>>} |
26 * @type Object<string, Array<number>> | |
27 */ | 26 */ |
28 this.valueLists_ = {}; | 27 this.valueLists_ = {}; |
29 | 28 |
30 /** | 29 /** |
31 * The first time, after this object was most recently initialized or emptied, | 30 * The first time, after this object was most recently initialized or emptied, |
32 * at which a value was added to this object. | 31 * at which a value was added to this object. |
33 * @private | 32 * @private {?number} |
34 * @type {?number} | |
35 */ | 33 */ |
36 this.timeOfFirstValue_ = null; | 34 this.timeOfFirstValue_ = null; |
37 }; | 35 }; |
38 | 36 |
39 /** | 37 /** |
40 * Adds values to this object. | 38 * Adds values to this object. |
41 * | 39 * |
42 * @param {Object<string, number>} newValues | 40 * @param {Object<string, number>} newValues |
43 */ | 41 */ |
44 remoting.StatsAccumulator.prototype.add = function(newValues) { | 42 remoting.StatsAccumulator.prototype.add = function(newValues) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 * @return {Array<number>} the list of values for that key | 115 * @return {Array<number>} the list of values for that key |
118 */ | 116 */ |
119 remoting.StatsAccumulator.prototype.getValueList = function(key) { | 117 remoting.StatsAccumulator.prototype.getValueList = function(key) { |
120 var valueList = this.valueLists_[key]; | 118 var valueList = this.valueLists_[key]; |
121 if (!valueList) { | 119 if (!valueList) { |
122 valueList = []; | 120 valueList = []; |
123 this.valueLists_[key] = valueList; | 121 this.valueLists_[key] = valueList; |
124 } | 122 } |
125 return valueList; | 123 return valueList; |
126 }; | 124 }; |
OLD | NEW |