| 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 * Any changes to the values here need to be coordinated with the host and | 9 * Any changes to the values here need to be coordinated with the host and |
| 10 * server/log proto code. | 10 * server/log proto code. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 */ | 22 */ |
| 23 remoting.ServerLogEntry = function() { | 23 remoting.ServerLogEntry = function() { |
| 24 /** @type Object.<string, string> */ this.dict = {}; | 24 /** @type Object.<string, string> */ this.dict = {}; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 /** @private */ | 27 /** @private */ |
| 28 remoting.ServerLogEntry.KEY_EVENT_NAME_ = 'event-name'; | 28 remoting.ServerLogEntry.KEY_EVENT_NAME_ = 'event-name'; |
| 29 /** @private */ | 29 /** @private */ |
| 30 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_ = 'session-state'; | 30 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_ = 'session-state'; |
| 31 /** @private */ | 31 /** @private */ |
| 32 remoting.ServerLogEntry.VALUE_EVENT_NAME_SIGNAL_STRATEGY_PROGRESS_ = |
| 33 'signal-strategy-progress'; |
| 34 /** @private */ |
| 32 remoting.ServerLogEntry.KEY_SESSION_ID_ = 'session-id'; | 35 remoting.ServerLogEntry.KEY_SESSION_ID_ = 'session-id'; |
| 33 /** @private */ | 36 /** @private */ |
| 34 remoting.ServerLogEntry.KEY_ROLE_ = 'role'; | 37 remoting.ServerLogEntry.KEY_ROLE_ = 'role'; |
| 35 /** @private */ | 38 /** @private */ |
| 36 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_ = 'client'; | 39 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_ = 'client'; |
| 37 /** @private */ | 40 /** @private */ |
| 38 remoting.ServerLogEntry.KEY_SESSION_STATE_ = 'session-state'; | 41 remoting.ServerLogEntry.KEY_SESSION_STATE_ = 'session-state'; |
| 39 /** @private */ | 42 /** @private */ |
| 40 remoting.ServerLogEntry.KEY_CONNECTION_TYPE_ = 'connection-type'; | 43 remoting.ServerLogEntry.KEY_CONNECTION_TYPE_ = 'connection-type'; |
| 44 /** @private */ |
| 45 remoting.ServerLogEntry.KEY_SIGNAL_STRATEGY_PROGRESS_ = |
| 46 'signal-strategy-progress'; |
| 47 /** @private */ |
| 48 remoting.ServerLogEntry.KEY_SIGNAL_STRATEGY_ELAPSED_TIME_ = |
| 49 'signal-strategy-elapsed-time'; |
| 41 | 50 |
| 42 /** | 51 /** |
| 43 * @private | 52 * @private |
| 44 * @param {remoting.ClientSession.State} state | 53 * @param {remoting.ClientSession.State} state |
| 45 * @return {string} | 54 * @return {string} |
| 46 */ | 55 */ |
| 47 remoting.ServerLogEntry.getValueForSessionState = function(state) { | 56 remoting.ServerLogEntry.getValueForSessionState_ = function(state) { |
| 48 switch(state) { | 57 switch(state) { |
| 49 case remoting.ClientSession.State.UNKNOWN: | 58 case remoting.ClientSession.State.UNKNOWN: |
| 50 return 'unknown'; | 59 return 'unknown'; |
| 51 case remoting.ClientSession.State.CREATED: | 60 case remoting.ClientSession.State.CREATED: |
| 52 return 'created'; | 61 return 'created'; |
| 53 case remoting.ClientSession.State.CONNECTING: | 62 case remoting.ClientSession.State.CONNECTING: |
| 54 return 'connecting'; | 63 return 'connecting'; |
| 55 case remoting.ClientSession.State.INITIALIZING: | 64 case remoting.ClientSession.State.INITIALIZING: |
| 56 return 'initializing'; | 65 return 'initializing'; |
| 57 case remoting.ClientSession.State.CONNECTED: | 66 case remoting.ClientSession.State.CONNECTED: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 70 }; | 79 }; |
| 71 | 80 |
| 72 /** @private */ | 81 /** @private */ |
| 73 remoting.ServerLogEntry.KEY_CONNECTION_ERROR_ = 'connection-error'; | 82 remoting.ServerLogEntry.KEY_CONNECTION_ERROR_ = 'connection-error'; |
| 74 | 83 |
| 75 /** | 84 /** |
| 76 * @private | 85 * @private |
| 77 * @param {remoting.Error} connectionError | 86 * @param {remoting.Error} connectionError |
| 78 * @return {string} | 87 * @return {string} |
| 79 */ | 88 */ |
| 80 remoting.ServerLogEntry.getValueForError = | 89 remoting.ServerLogEntry.getValueForError_ = function(connectionError) { |
| 81 function(connectionError) { | |
| 82 // Directory service should be updated if a new string is added here as | 90 // Directory service should be updated if a new string is added here as |
| 83 // otherwise the error code will be ignored (i.e. recorded as 0 instead). | 91 // otherwise the error code will be ignored (i.e. recorded as 0 instead). |
| 84 switch(connectionError) { | 92 switch(connectionError) { |
| 85 case remoting.Error.NONE: | 93 case remoting.Error.NONE: |
| 86 return 'none'; | 94 return 'none'; |
| 87 case remoting.Error.INVALID_ACCESS_CODE: | 95 case remoting.Error.INVALID_ACCESS_CODE: |
| 88 return 'invalid-access-code'; | 96 return 'invalid-access-code'; |
| 89 case remoting.Error.MISSING_PLUGIN: | 97 case remoting.Error.MISSING_PLUGIN: |
| 90 return 'missing_plugin'; | 98 return 'missing_plugin'; |
| 91 case remoting.Error.AUTHENTICATION_FAILED: | 99 case remoting.Error.AUTHENTICATION_FAILED: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 /** @private */ | 176 /** @private */ |
| 169 remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_ = 'unknown'; | 177 remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_ = 'unknown'; |
| 170 | 178 |
| 171 /** | 179 /** |
| 172 * Sets one field in this log entry. | 180 * Sets one field in this log entry. |
| 173 * | 181 * |
| 174 * @private | 182 * @private |
| 175 * @param {string} key | 183 * @param {string} key |
| 176 * @param {string} value | 184 * @param {string} value |
| 177 */ | 185 */ |
| 178 remoting.ServerLogEntry.prototype.set = function(key, value) { | 186 remoting.ServerLogEntry.prototype.set_ = function(key, value) { |
| 179 this.dict[key] = value; | 187 this.dict[key] = value; |
| 180 }; | 188 }; |
| 181 | 189 |
| 182 /** | 190 /** |
| 183 * Converts this object into an XML stanza. | 191 * Converts this object into an XML stanza. |
| 184 * | 192 * |
| 185 * @return {string} | 193 * @return {string} |
| 186 */ | 194 */ |
| 187 remoting.ServerLogEntry.prototype.toStanza = function() { | 195 remoting.ServerLogEntry.prototype.toStanza = function() { |
| 188 var stanza = '<gr:entry '; | 196 var stanza = '<gr:entry '; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 210 * Makes a log entry for a change of client session state. | 218 * Makes a log entry for a change of client session state. |
| 211 * | 219 * |
| 212 * @param {remoting.ClientSession.State} state | 220 * @param {remoting.ClientSession.State} state |
| 213 * @param {remoting.Error} connectionError | 221 * @param {remoting.Error} connectionError |
| 214 * @param {remoting.ClientSession.Mode} mode | 222 * @param {remoting.ClientSession.Mode} mode |
| 215 * @return {remoting.ServerLogEntry} | 223 * @return {remoting.ServerLogEntry} |
| 216 */ | 224 */ |
| 217 remoting.ServerLogEntry.makeClientSessionStateChange = function(state, | 225 remoting.ServerLogEntry.makeClientSessionStateChange = function(state, |
| 218 connectionError, mode) { | 226 connectionError, mode) { |
| 219 var entry = new remoting.ServerLogEntry(); | 227 var entry = new remoting.ServerLogEntry(); |
| 220 entry.set(remoting.ServerLogEntry.KEY_ROLE_, | 228 entry.set_(remoting.ServerLogEntry.KEY_ROLE_, |
| 221 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); | 229 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 222 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, | 230 entry.set_(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 223 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_); | 231 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_); |
| 224 entry.set(remoting.ServerLogEntry.KEY_SESSION_STATE_, | 232 entry.set_(remoting.ServerLogEntry.KEY_SESSION_STATE_, |
| 225 remoting.ServerLogEntry.getValueForSessionState(state)); | 233 remoting.ServerLogEntry.getValueForSessionState_(state)); |
| 226 if (connectionError != remoting.Error.NONE) { | 234 if (connectionError != remoting.Error.NONE) { |
| 227 entry.set(remoting.ServerLogEntry.KEY_CONNECTION_ERROR_, | 235 entry.set_(remoting.ServerLogEntry.KEY_CONNECTION_ERROR_, |
| 228 remoting.ServerLogEntry.getValueForError(connectionError)); | 236 remoting.ServerLogEntry.getValueForError_(connectionError)); |
| 229 } | 237 } |
| 230 entry.addModeField(mode); | 238 entry.addModeField(mode); |
| 231 return entry; | 239 return entry; |
| 232 }; | 240 }; |
| 233 | 241 |
| 234 /** | 242 /** |
| 235 * Adds a session duration to a log entry. | 243 * Adds a session duration to a log entry. |
| 236 * | 244 * |
| 237 * @param {number} sessionDuration | 245 * @param {number} sessionDuration |
| 238 */ | 246 */ |
| 239 remoting.ServerLogEntry.prototype.addSessionDurationField = function( | 247 remoting.ServerLogEntry.prototype.addSessionDurationField = function( |
| 240 sessionDuration) { | 248 sessionDuration) { |
| 241 this.set(remoting.ServerLogEntry.KEY_SESSION_DURATION_, | 249 this.set_(remoting.ServerLogEntry.KEY_SESSION_DURATION_, |
| 242 sessionDuration.toString()); | 250 sessionDuration.toString()); |
| 243 }; | 251 }; |
| 244 | 252 |
| 245 /** | 253 /** |
| 246 * Makes a log entry for a set of connection statistics. | 254 * Makes a log entry for a set of connection statistics. |
| 247 * Returns null if all the statistics were zero. | 255 * Returns null if all the statistics were zero. |
| 248 * | 256 * |
| 249 * @param {remoting.StatsAccumulator} statsAccumulator | 257 * @param {remoting.StatsAccumulator} statsAccumulator |
| 250 * @param {string} connectionType | 258 * @param {string} connectionType |
| 251 * @param {remoting.ClientSession.Mode} mode | 259 * @param {remoting.ClientSession.Mode} mode |
| 252 * @return {?remoting.ServerLogEntry} | 260 * @return {?remoting.ServerLogEntry} |
| 253 */ | 261 */ |
| 254 remoting.ServerLogEntry.makeStats = function(statsAccumulator, | 262 remoting.ServerLogEntry.makeStats = function(statsAccumulator, |
| 255 connectionType, | 263 connectionType, |
| 256 mode) { | 264 mode) { |
| 257 var entry = new remoting.ServerLogEntry(); | 265 var entry = new remoting.ServerLogEntry(); |
| 258 entry.set(remoting.ServerLogEntry.KEY_ROLE_, | 266 entry.set_(remoting.ServerLogEntry.KEY_ROLE_, |
| 259 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); | 267 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 260 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, | 268 entry.set_(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 261 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_); | 269 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_); |
| 262 if (connectionType) { | 270 if (connectionType) { |
| 263 entry.set(remoting.ServerLogEntry.KEY_CONNECTION_TYPE_, | 271 entry.set_(remoting.ServerLogEntry.KEY_CONNECTION_TYPE_, |
| 264 connectionType); | 272 connectionType); |
| 265 } | 273 } |
| 266 entry.addModeField(mode); | 274 entry.addModeField(mode); |
| 267 var nonZero = false; | 275 var nonZero = false; |
| 268 nonZero |= entry.addStatsField( | 276 nonZero |= entry.addStatsField_( |
| 269 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_, | 277 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_, |
| 270 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); | 278 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); |
| 271 nonZero |= entry.addStatsField( | 279 nonZero |= entry.addStatsField_( |
| 272 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_, | 280 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_, |
| 273 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); | 281 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); |
| 274 nonZero |= entry.addStatsField( | 282 nonZero |= entry.addStatsField_( |
| 275 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_, | 283 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_, |
| 276 remoting.ClientSession.STATS_KEY_ENCODE_LATENCY, statsAccumulator); | 284 remoting.ClientSession.STATS_KEY_ENCODE_LATENCY, statsAccumulator); |
| 277 nonZero |= entry.addStatsField( | 285 nonZero |= entry.addStatsField_( |
| 278 remoting.ServerLogEntry.KEY_DECODE_LATENCY_, | 286 remoting.ServerLogEntry.KEY_DECODE_LATENCY_, |
| 279 remoting.ClientSession.STATS_KEY_DECODE_LATENCY, statsAccumulator); | 287 remoting.ClientSession.STATS_KEY_DECODE_LATENCY, statsAccumulator); |
| 280 nonZero |= entry.addStatsField( | 288 nonZero |= entry.addStatsField_( |
| 281 remoting.ServerLogEntry.KEY_RENDER_LATENCY_, | 289 remoting.ServerLogEntry.KEY_RENDER_LATENCY_, |
| 282 remoting.ClientSession.STATS_KEY_RENDER_LATENCY, statsAccumulator); | 290 remoting.ClientSession.STATS_KEY_RENDER_LATENCY, statsAccumulator); |
| 283 nonZero |= entry.addStatsField( | 291 nonZero |= entry.addStatsField_( |
| 284 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_, | 292 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_, |
| 285 remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY, statsAccumulator); | 293 remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY, statsAccumulator); |
| 286 if (nonZero) { | 294 if (nonZero) { |
| 287 return entry; | 295 return entry; |
| 288 } | 296 } |
| 289 return null; | 297 return null; |
| 290 }; | 298 }; |
| 291 | 299 |
| 292 /** | 300 /** |
| 293 * Adds one connection statistic to a log entry. | 301 * Adds one connection statistic to a log entry. |
| 294 * | 302 * |
| 295 * @private | 303 * @private |
| 296 * @param {string} entryKey | 304 * @param {string} entryKey |
| 297 * @param {string} statsKey | 305 * @param {string} statsKey |
| 298 * @param {remoting.StatsAccumulator} statsAccumulator | 306 * @param {remoting.StatsAccumulator} statsAccumulator |
| 299 * @return {boolean} whether the statistic is non-zero | 307 * @return {boolean} whether the statistic is non-zero |
| 300 */ | 308 */ |
| 301 remoting.ServerLogEntry.prototype.addStatsField = function( | 309 remoting.ServerLogEntry.prototype.addStatsField_ = function( |
| 302 entryKey, statsKey, statsAccumulator) { | 310 entryKey, statsKey, statsAccumulator) { |
| 303 var val = statsAccumulator.calcMean(statsKey); | 311 var val = statsAccumulator.calcMean(statsKey); |
| 304 this.set(entryKey, val.toFixed(2)); | 312 this.set_(entryKey, val.toFixed(2)); |
| 305 return (val != 0); | 313 return (val != 0); |
| 306 }; | 314 }; |
| 307 | 315 |
| 308 /** | 316 /** |
| 309 * Makes a log entry for a "this session ID is old" event. | 317 * Makes a log entry for a "this session ID is old" event. |
| 310 * | 318 * |
| 311 * @param {string} sessionId | 319 * @param {string} sessionId |
| 312 * @param {remoting.ClientSession.Mode} mode | 320 * @param {remoting.ClientSession.Mode} mode |
| 313 * @return {remoting.ServerLogEntry} | 321 * @return {remoting.ServerLogEntry} |
| 314 */ | 322 */ |
| 315 remoting.ServerLogEntry.makeSessionIdOld = function(sessionId, mode) { | 323 remoting.ServerLogEntry.makeSessionIdOld = function(sessionId, mode) { |
| 316 var entry = new remoting.ServerLogEntry(); | 324 var entry = new remoting.ServerLogEntry(); |
| 317 entry.set(remoting.ServerLogEntry.KEY_ROLE_, | 325 entry.set_(remoting.ServerLogEntry.KEY_ROLE_, |
| 318 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); | 326 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 319 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, | 327 entry.set_(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 320 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_ID_OLD_); | 328 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_ID_OLD_); |
| 321 entry.addSessionIdField(sessionId); | 329 entry.addSessionIdField(sessionId); |
| 322 entry.addModeField(mode); | 330 entry.addModeField(mode); |
| 323 return entry; | 331 return entry; |
| 324 }; | 332 }; |
| 325 | 333 |
| 326 /** | 334 /** |
| 327 * Makes a log entry for a "this session ID is new" event. | 335 * Makes a log entry for a "this session ID is new" event. |
| 328 * | 336 * |
| 329 * @param {string} sessionId | 337 * @param {string} sessionId |
| 330 * @param {remoting.ClientSession.Mode} mode | 338 * @param {remoting.ClientSession.Mode} mode |
| 331 * @return {remoting.ServerLogEntry} | 339 * @return {remoting.ServerLogEntry} |
| 332 */ | 340 */ |
| 333 remoting.ServerLogEntry.makeSessionIdNew = function(sessionId, mode) { | 341 remoting.ServerLogEntry.makeSessionIdNew = function(sessionId, mode) { |
| 334 var entry = new remoting.ServerLogEntry(); | 342 var entry = new remoting.ServerLogEntry(); |
| 335 entry.set(remoting.ServerLogEntry.KEY_ROLE_, | 343 entry.set_(remoting.ServerLogEntry.KEY_ROLE_, |
| 336 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); | 344 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 337 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, | 345 entry.set_(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 338 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_ID_NEW_); | 346 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_ID_NEW_); |
| 339 entry.addSessionIdField(sessionId); | 347 entry.addSessionIdField(sessionId); |
| 340 entry.addModeField(mode); | 348 entry.addModeField(mode); |
| 341 return entry; | 349 return entry; |
| 342 }; | 350 }; |
| 343 | 351 |
| 344 /** | 352 /** |
| 353 * Makes a log entry for a "signal strategy fallback" event. |
| 354 * |
| 355 * @param {string} sessionId |
| 356 * @param {remoting.FallbackSignalStrategy.Progress} progress |
| 357 * @param {number} elapsedTimeInMs |
| 358 * @return {remoting.ServerLogEntry} |
| 359 */ |
| 360 remoting.ServerLogEntry.makeSignalStrategyProgress = |
| 361 function(sessionId, progress, elapsedTimeInMs) { |
| 362 var entry = new remoting.ServerLogEntry(); |
| 363 entry.set_(remoting.ServerLogEntry.KEY_ROLE_, |
| 364 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 365 entry.set_( |
| 366 remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 367 remoting.ServerLogEntry.VALUE_EVENT_NAME_SIGNAL_STRATEGY_PROGRESS_); |
| 368 entry.addSessionIdField(sessionId); |
| 369 entry.set_(remoting.ServerLogEntry.KEY_SIGNAL_STRATEGY_PROGRESS_, |
| 370 progress); |
| 371 entry.set_(remoting.ServerLogEntry.KEY_SIGNAL_STRATEGY_ELAPSED_TIME_, |
| 372 String(elapsedTimeInMs)); |
| 373 |
| 374 return entry; |
| 375 }; |
| 376 |
| 377 /** |
| 345 * Adds a session ID field to this log entry. | 378 * Adds a session ID field to this log entry. |
| 346 * | 379 * |
| 347 * @param {string} sessionId | 380 * @param {string} sessionId |
| 348 */ | 381 */ |
| 349 remoting.ServerLogEntry.prototype.addSessionIdField = function(sessionId) { | 382 remoting.ServerLogEntry.prototype.addSessionIdField = function(sessionId) { |
| 350 this.set(remoting.ServerLogEntry.KEY_SESSION_ID_, sessionId); | 383 this.set_(remoting.ServerLogEntry.KEY_SESSION_ID_, sessionId); |
| 351 } | 384 } |
| 352 | 385 |
| 353 /** | 386 /** |
| 354 * Adds fields describing the host to this log entry. | 387 * Adds fields describing the host to this log entry. |
| 355 */ | 388 */ |
| 356 remoting.ServerLogEntry.prototype.addHostFields = function() { | 389 remoting.ServerLogEntry.prototype.addHostFields = function() { |
| 357 var host = remoting.ServerLogEntry.getHostData(); | 390 var host = remoting.ServerLogEntry.getHostData_(); |
| 358 if (host) { | 391 if (host) { |
| 359 if (host.os_name.length > 0) { | 392 if (host.os_name.length > 0) { |
| 360 this.set(remoting.ServerLogEntry.KEY_OS_NAME_, host.os_name); | 393 this.set_(remoting.ServerLogEntry.KEY_OS_NAME_, host.os_name); |
| 361 } | 394 } |
| 362 if (host.os_version.length > 0) { | 395 if (host.os_version.length > 0) { |
| 363 this.set(remoting.ServerLogEntry.KEY_OS_VERSION_, host.os_version); | 396 this.set_(remoting.ServerLogEntry.KEY_OS_VERSION_, host.os_version); |
| 364 } | 397 } |
| 365 if (host.cpu.length > 0) { | 398 if (host.cpu.length > 0) { |
| 366 this.set(remoting.ServerLogEntry.KEY_CPU_, host.cpu); | 399 this.set_(remoting.ServerLogEntry.KEY_CPU_, host.cpu); |
| 367 } | 400 } |
| 368 } | 401 } |
| 369 }; | 402 }; |
| 370 | 403 |
| 371 /** | 404 /** |
| 372 * Extracts host data from the userAgent string. | 405 * Extracts host data from the userAgent string. |
| 373 * | 406 * |
| 374 * @private | 407 * @private |
| 375 * @return {{os_name:string, os_version:string, cpu:string} | null} | 408 * @return {{os_name:string, os_version:string, cpu:string} | null} |
| 376 */ | 409 */ |
| 377 remoting.ServerLogEntry.getHostData = function() { | 410 remoting.ServerLogEntry.getHostData_ = function() { |
| 378 return remoting.ServerLogEntry.extractHostDataFrom(navigator.userAgent); | 411 return remoting.ServerLogEntry.extractHostDataFrom_(navigator.userAgent); |
| 379 }; | 412 }; |
| 380 | 413 |
| 381 /** | 414 /** |
| 382 * Extracts host data from the given userAgent string. | 415 * Extracts host data from the given userAgent string. |
| 383 * | 416 * |
| 384 * @private | 417 * @private |
| 385 * @param {string} s | 418 * @param {string} s |
| 386 * @return {{os_name:string, os_version:string, cpu:string} | null} | 419 * @return {{os_name:string, os_version:string, cpu:string} | null} |
| 387 */ | 420 */ |
| 388 remoting.ServerLogEntry.extractHostDataFrom = function(s) { | 421 remoting.ServerLogEntry.extractHostDataFrom_ = function(s) { |
| 389 // Sample userAgent strings: | 422 // Sample userAgent strings: |
| 390 // 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 ' + | 423 // 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 ' + |
| 391 // '(KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2' | 424 // '(KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2' |
| 392 // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 ' + | 425 // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 ' + |
| 393 // '(KHTML, like Gecko) Chrome/17.0.933.0 Safari/535.8' | 426 // '(KHTML, like Gecko) Chrome/17.0.933.0 Safari/535.8' |
| 394 // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 ' + | 427 // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 ' + |
| 395 // '(KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' | 428 // '(KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' |
| 396 // 'Mozilla/5.0 (X11; CrOS i686 14.811.154) AppleWebKit/535.1 ' + | 429 // 'Mozilla/5.0 (X11; CrOS i686 14.811.154) AppleWebKit/535.1 ' + |
| 397 // '(KHTML, like Gecko) Chrome/14.0.835.204 Safari/535.1' | 430 // '(KHTML, like Gecko) Chrome/14.0.835.204 Safari/535.1' |
| 398 var match = new RegExp('Windows NT ([0-9\\.]*)').exec(s); | 431 var match = new RegExp('Windows NT ([0-9\\.]*)').exec(s); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 429 } | 462 } |
| 430 return null; | 463 return null; |
| 431 }; | 464 }; |
| 432 | 465 |
| 433 /** | 466 /** |
| 434 * Adds a field specifying the browser version to this log entry. | 467 * Adds a field specifying the browser version to this log entry. |
| 435 */ | 468 */ |
| 436 remoting.ServerLogEntry.prototype.addChromeVersionField = function() { | 469 remoting.ServerLogEntry.prototype.addChromeVersionField = function() { |
| 437 var version = remoting.getChromeVersion(); | 470 var version = remoting.getChromeVersion(); |
| 438 if (version != null) { | 471 if (version != null) { |
| 439 this.set(remoting.ServerLogEntry.KEY_BROWSER_VERSION_, version); | 472 this.set_(remoting.ServerLogEntry.KEY_BROWSER_VERSION_, version); |
| 440 } | 473 } |
| 441 }; | 474 }; |
| 442 | 475 |
| 443 /** | 476 /** |
| 444 * Adds a field specifying the webapp version to this log entry. | 477 * Adds a field specifying the webapp version to this log entry. |
| 445 */ | 478 */ |
| 446 remoting.ServerLogEntry.prototype.addWebappVersionField = function() { | 479 remoting.ServerLogEntry.prototype.addWebappVersionField = function() { |
| 447 var manifest = chrome.runtime.getManifest(); | 480 var manifest = chrome.runtime.getManifest(); |
| 448 if (manifest && manifest.version) { | 481 if (manifest && manifest.version) { |
| 449 this.set(remoting.ServerLogEntry.KEY_WEBAPP_VERSION_, manifest.version); | 482 this.set_(remoting.ServerLogEntry.KEY_WEBAPP_VERSION_, manifest.version); |
| 450 } | 483 } |
| 451 }; | 484 }; |
| 452 | 485 |
| 453 /** | 486 /** |
| 454 * Adds a field specifying the mode to this log entry. | 487 * Adds a field specifying the mode to this log entry. |
| 455 * | 488 * |
| 456 * @param {remoting.ClientSession.Mode} mode | 489 * @param {remoting.ClientSession.Mode} mode |
| 457 */ | 490 */ |
| 458 remoting.ServerLogEntry.prototype.addModeField = function(mode) { | 491 remoting.ServerLogEntry.prototype.addModeField = function(mode) { |
| 459 this.set(remoting.ServerLogEntry.KEY_MODE_, | 492 this.set_(remoting.ServerLogEntry.KEY_MODE_, |
| 460 remoting.ServerLogEntry.getModeField(mode)); | 493 remoting.ServerLogEntry.getModeField_(mode)); |
| 461 }; | 494 }; |
| 462 | 495 |
| 463 /** | 496 /** |
| 464 * Gets the value of the mode field to be put in a log entry. | 497 * Gets the value of the mode field to be put in a log entry. |
| 465 * | 498 * |
| 466 * @private | 499 * @private |
| 467 * @param {remoting.ClientSession.Mode} mode | 500 * @param {remoting.ClientSession.Mode} mode |
| 468 * @return {string} | 501 * @return {string} |
| 469 */ | 502 */ |
| 470 remoting.ServerLogEntry.getModeField = function(mode) { | 503 remoting.ServerLogEntry.getModeField_ = function(mode) { |
| 471 switch(mode) { | 504 switch(mode) { |
| 472 case remoting.ClientSession.Mode.IT2ME: | 505 case remoting.ClientSession.Mode.IT2ME: |
| 473 return remoting.ServerLogEntry.VALUE_MODE_IT2ME_; | 506 return remoting.ServerLogEntry.VALUE_MODE_IT2ME_; |
| 474 case remoting.ClientSession.Mode.ME2ME: | 507 case remoting.ClientSession.Mode.ME2ME: |
| 475 return remoting.ServerLogEntry.VALUE_MODE_ME2ME_; | 508 return remoting.ServerLogEntry.VALUE_MODE_ME2ME_; |
| 476 case remoting.ClientSession.Mode.APP_REMOTING: | 509 case remoting.ClientSession.Mode.APP_REMOTING: |
| 477 return remoting.ServerLogEntry.VALUE_MODE_APP_REMOTING_; | 510 return remoting.ServerLogEntry.VALUE_MODE_APP_REMOTING_; |
| 478 default: | 511 default: |
| 479 return remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_; | 512 return remoting.ServerLogEntry.VALUE_MODE_UNKNOWN_; |
| 480 } | 513 } |
| 481 }; | 514 }; |
| OLD | NEW |