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 | 6 * @fileoverview |
7 * A class of server log entries. | 7 * A class of server log entries. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 /** @suppress {duplicate} */ | 12 /** @suppress {duplicate} */ |
13 var remoting = remoting || {}; | 13 var remoting = remoting || {}; |
14 | 14 |
15 /** | 15 /** |
16 * @private | 16 * @private |
17 * @constructor | 17 * @constructor |
18 */ | 18 */ |
19 remoting.ServerLogEntry = function() { | 19 remoting.ServerLogEntry = function() { |
20 /** @type Object.<string, string> */ this.dict = {}; | 20 /** @type Object.<string, string> */ this.dict = {}; |
21 }; | 21 }; |
22 | 22 |
23 /** @private */ | 23 /** @private */ |
24 remoting.ServerLogEntry.KEY_EVENT_NAME_ = 'event-name'; | 24 remoting.ServerLogEntry.KEY_EVENT_NAME_ = 'event-name'; |
25 /** @private */ | 25 /** @private */ |
26 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_ = | 26 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_ = 'session-state'; |
27 'session-state'; | |
28 | |
29 /** @private */ | 27 /** @private */ |
30 remoting.ServerLogEntry.KEY_SESSION_ID_ = 'session-id'; | 28 remoting.ServerLogEntry.KEY_SESSION_ID_ = 'session-id'; |
31 | |
32 /** @private */ | 29 /** @private */ |
33 remoting.ServerLogEntry.KEY_ROLE_ = 'role'; | 30 remoting.ServerLogEntry.KEY_ROLE_ = 'role'; |
34 /** @private */ | 31 /** @private */ |
35 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_ = 'client'; | 32 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_ = 'client'; |
36 | |
37 /** @private */ | 33 /** @private */ |
38 remoting.ServerLogEntry.KEY_SESSION_STATE_ = 'session-state'; | 34 remoting.ServerLogEntry.KEY_SESSION_STATE_ = 'session-state'; |
| 35 /** @private */ |
| 36 remoting.ServerLogEntry.KEY_CONNECTION_TYPE_ = 'connection-type'; |
39 | 37 |
40 /** | 38 /** |
41 * @private | 39 * @private |
42 * @param {remoting.ClientSession.State} state | 40 * @param {remoting.ClientSession.State} state |
43 * @return {string} | 41 * @return {string} |
44 */ | 42 */ |
45 remoting.ServerLogEntry.getValueForSessionState = function(state) { | 43 remoting.ServerLogEntry.getValueForSessionState = function(state) { |
46 switch(state) { | 44 switch(state) { |
47 case remoting.ClientSession.State.UNKNOWN: | 45 case remoting.ClientSession.State.UNKNOWN: |
48 return 'unknown'; | 46 return 'unknown'; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 sessionDuration) { | 232 sessionDuration) { |
235 this.set(remoting.ServerLogEntry.KEY_SESSION_DURATION_, | 233 this.set(remoting.ServerLogEntry.KEY_SESSION_DURATION_, |
236 sessionDuration.toString()); | 234 sessionDuration.toString()); |
237 }; | 235 }; |
238 | 236 |
239 /** | 237 /** |
240 * Makes a log entry for a set of connection statistics. | 238 * Makes a log entry for a set of connection statistics. |
241 * Returns null if all the statistics were zero. | 239 * Returns null if all the statistics were zero. |
242 * | 240 * |
243 * @param {remoting.StatsAccumulator} statsAccumulator | 241 * @param {remoting.StatsAccumulator} statsAccumulator |
| 242 * @param {string} connectionType |
244 * @param {remoting.ClientSession.Mode} mode | 243 * @param {remoting.ClientSession.Mode} mode |
245 * @return {?remoting.ServerLogEntry} | 244 * @return {?remoting.ServerLogEntry} |
246 */ | 245 */ |
247 remoting.ServerLogEntry.makeStats = function(statsAccumulator, mode) { | 246 remoting.ServerLogEntry.makeStats = function(statsAccumulator, |
| 247 connectionType, |
| 248 mode) { |
248 var entry = new remoting.ServerLogEntry(); | 249 var entry = new remoting.ServerLogEntry(); |
249 entry.set(remoting.ServerLogEntry.KEY_ROLE_, | 250 entry.set(remoting.ServerLogEntry.KEY_ROLE_, |
250 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); | 251 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
251 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, | 252 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
252 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_); | 253 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_); |
| 254 if (connectionType) { |
| 255 entry.set(remoting.ServerLogEntry.KEY_CONNECTION_TYPE_, |
| 256 connectionType); |
| 257 } |
253 entry.addModeField(mode); | 258 entry.addModeField(mode); |
254 var nonZero = false; | 259 var nonZero = false; |
255 nonZero |= entry.addStatsField( | 260 nonZero |= entry.addStatsField( |
256 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_, | 261 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_, |
257 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); | 262 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); |
258 nonZero |= entry.addStatsField( | 263 nonZero |= entry.addStatsField( |
259 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_, | 264 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_, |
260 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); | 265 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); |
261 nonZero |= entry.addStatsField( | 266 nonZero |= entry.addStatsField( |
262 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_, | 267 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 remoting.ServerLogEntry.getModeField = function(mode) { | 462 remoting.ServerLogEntry.getModeField = function(mode) { |
458 switch(mode) { | 463 switch(mode) { |
459 case remoting.ClientSession.Mode.IT2ME: | 464 case remoting.ClientSession.Mode.IT2ME: |
460 return remoting.ServerLogEntry.VALUE_MODE_IT2ME_; | 465 return remoting.ServerLogEntry.VALUE_MODE_IT2ME_; |
461 case remoting.ClientSession.Mode.ME2ME: | 466 case remoting.ClientSession.Mode.ME2ME: |
462 return remoting.ServerLogEntry.VALUE_MODE_ME2ME_; | 467 return remoting.ServerLogEntry.VALUE_MODE_ME2ME_; |
463 default: | 468 default: |
464 return remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_; | 469 return remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_; |
465 } | 470 } |
466 }; | 471 }; |
OLD | NEW |