Chromium Code Reviews| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_ = "encode-latency"; | 132 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_ = "encode-latency"; |
| 133 /** @private */ | 133 /** @private */ |
| 134 remoting.ServerLogEntry.KEY_DECODE_LATENCY_ = "decode-latency"; | 134 remoting.ServerLogEntry.KEY_DECODE_LATENCY_ = "decode-latency"; |
| 135 /** @private */ | 135 /** @private */ |
| 136 remoting.ServerLogEntry.KEY_RENDER_LATENCY_ = "render-latency"; | 136 remoting.ServerLogEntry.KEY_RENDER_LATENCY_ = "render-latency"; |
| 137 /** @private */ | 137 /** @private */ |
| 138 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_ = "roundtrip-latency"; | 138 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_ = "roundtrip-latency"; |
| 139 | 139 |
| 140 /** @private */ | 140 /** @private */ |
| 141 remoting.ServerLogEntry.KEY_OS_NAME_ = 'os-name'; | 141 remoting.ServerLogEntry.KEY_OS_NAME_ = 'os-name'; |
| 142 /** @private */ | |
| 143 remoting.ServerLogEntry.VALUE_OS_NAME_WINDOWS_ = 'Windows'; | |
| 144 /** @private */ | |
| 145 remoting.ServerLogEntry.VALUE_OS_NAME_LINUX_ = 'Linux'; | |
| 146 /** @private */ | |
| 147 remoting.ServerLogEntry.VALUE_OS_NAME_MAC_ = 'Mac'; | |
| 148 /** @private */ | |
| 149 remoting.ServerLogEntry.VALUE_OS_NAME_CHROMEOS_ = 'ChromeOS'; | |
| 150 | 142 |
| 151 /** @private */ | 143 /** @private */ |
| 152 remoting.ServerLogEntry.KEY_OS_VERSION_ = 'os-version'; | 144 remoting.ServerLogEntry.KEY_OS_VERSION_ = 'os-version'; |
| 153 | 145 |
| 154 /** @private */ | 146 /** @private */ |
| 155 remoting.ServerLogEntry.KEY_CPU_ = 'cpu'; | 147 remoting.ServerLogEntry.KEY_CPU_ = 'cpu'; |
| 156 | 148 |
| 157 /** @private */ | 149 /** @private */ |
| 158 remoting.ServerLogEntry.KEY_BROWSER_VERSION_ = 'browser-version'; | 150 remoting.ServerLogEntry.KEY_BROWSER_VERSION_ = 'browser-version'; |
| 159 | 151 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 * @param {string} sessionId | 362 * @param {string} sessionId |
| 371 */ | 363 */ |
| 372 remoting.ServerLogEntry.prototype.addSessionIdField = function(sessionId) { | 364 remoting.ServerLogEntry.prototype.addSessionIdField = function(sessionId) { |
| 373 this.set_(remoting.ServerLogEntry.KEY_SESSION_ID_, sessionId); | 365 this.set_(remoting.ServerLogEntry.KEY_SESSION_ID_, sessionId); |
| 374 } | 366 } |
| 375 | 367 |
| 376 /** | 368 /** |
| 377 * Adds fields describing the host to this log entry. | 369 * Adds fields describing the host to this log entry. |
| 378 */ | 370 */ |
| 379 remoting.ServerLogEntry.prototype.addClientOSFields = function() { | 371 remoting.ServerLogEntry.prototype.addClientOSFields = function() { |
| 380 var host = remoting.ServerLogEntry.getHostData_(); | 372 var host = remoting.getSystemInfo(); |
|
Jamie
2015/06/06 01:05:41
This is a confusing name, given that the containin
kelvinp
2015/06/06 02:09:55
Done.
| |
| 381 if (host) { | 373 if (host) { |
| 382 if (host.os_name.length > 0) { | 374 if (host.os_name.length > 0) { |
| 383 this.set_(remoting.ServerLogEntry.KEY_OS_NAME_, host.os_name); | 375 this.set_(remoting.ServerLogEntry.KEY_OS_NAME_, host.os_name); |
| 384 } | 376 } |
| 385 if (host.os_version.length > 0) { | 377 if (host.os_version.length > 0) { |
| 386 this.set_(remoting.ServerLogEntry.KEY_OS_VERSION_, host.os_version); | 378 this.set_(remoting.ServerLogEntry.KEY_OS_VERSION_, host.os_version); |
| 387 } | 379 } |
| 388 if (host.cpu.length > 0) { | 380 if (host.cpu.length > 0) { |
| 389 this.set_(remoting.ServerLogEntry.KEY_CPU_, host.cpu); | 381 this.set_(remoting.ServerLogEntry.KEY_CPU_, host.cpu); |
| 390 } | 382 } |
| 391 } | 383 } |
| 392 }; | 384 }; |
| 393 | 385 |
| 394 /** | 386 /** |
| 395 * Extracts host data from the userAgent string. | |
| 396 * | |
| 397 * @private | |
| 398 * @return {{os_name:string, os_version:string, cpu:string} | null} | |
| 399 */ | |
| 400 remoting.ServerLogEntry.getHostData_ = function() { | |
| 401 return remoting.ServerLogEntry.extractHostDataFrom_(navigator.userAgent); | |
| 402 }; | |
| 403 | |
| 404 /** | |
| 405 * Extracts host data from the given userAgent string. | |
| 406 * | |
| 407 * @private | |
| 408 * @param {string} s | |
| 409 * @return {{os_name:string, os_version:string, cpu:string} | null} | |
| 410 */ | |
| 411 remoting.ServerLogEntry.extractHostDataFrom_ = function(s) { | |
| 412 // Sample userAgent strings: | |
| 413 // 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 ' + | |
| 414 // '(KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2' | |
| 415 // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 ' + | |
| 416 // '(KHTML, like Gecko) Chrome/17.0.933.0 Safari/535.8' | |
| 417 // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 ' + | |
| 418 // '(KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' | |
| 419 // 'Mozilla/5.0 (X11; CrOS i686 14.811.154) AppleWebKit/535.1 ' + | |
| 420 // '(KHTML, like Gecko) Chrome/14.0.835.204 Safari/535.1' | |
| 421 var match = new RegExp('Windows NT ([0-9\\.]*)').exec(s); | |
| 422 if (match && (match.length >= 2)) { | |
| 423 return { | |
| 424 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_WINDOWS_, | |
| 425 'os_version': match[1], | |
| 426 'cpu': '' | |
| 427 }; | |
| 428 } | |
| 429 match = new RegExp('Linux ([a-zA-Z0-9_]*)').exec(s); | |
| 430 if (match && (match.length >= 2)) { | |
| 431 return { | |
| 432 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_LINUX_, | |
| 433 'os_version' : '', | |
| 434 'cpu': match[1] | |
| 435 }; | |
| 436 } | |
| 437 match = new RegExp('([a-zA-Z]*) Mac OS X ([0-9_]*)').exec(s); | |
| 438 if (match && (match.length >= 3)) { | |
| 439 return { | |
| 440 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_MAC_, | |
| 441 'os_version': match[2].replace(/_/g, '.'), | |
| 442 'cpu': match[1] | |
| 443 }; | |
| 444 } | |
| 445 match = new RegExp('CrOS ([a-zA-Z0-9]*) ([0-9.]*)').exec(s); | |
| 446 if (match && (match.length >= 3)) { | |
| 447 return { | |
| 448 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_CHROMEOS_, | |
| 449 'os_version': match[2], | |
| 450 'cpu': match[1] | |
| 451 }; | |
| 452 } | |
| 453 return null; | |
| 454 }; | |
| 455 | |
| 456 /** | |
| 457 * Adds a field to this log entry specifying the time in seconds since the start | 387 * Adds a field to this log entry specifying the time in seconds since the start |
| 458 * of the session to the current event. | 388 * of the session to the current event. |
| 459 * @param {number} sessionDurationInSeconds | 389 * @param {number} sessionDurationInSeconds |
| 460 */ | 390 */ |
| 461 remoting.ServerLogEntry.prototype.addSessionDuration = | 391 remoting.ServerLogEntry.prototype.addSessionDuration = |
| 462 function(sessionDurationInSeconds) { | 392 function(sessionDurationInSeconds) { |
| 463 this.set_(remoting.ServerLogEntry.KEY_SESSION_DURATION_SECONDS_, | 393 this.set_(remoting.ServerLogEntry.KEY_SESSION_DURATION_SECONDS_, |
| 464 String(sessionDurationInSeconds)); | 394 String(sessionDurationInSeconds)); |
| 465 }; | 395 }; |
| 466 | 396 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 }; | 433 }; |
| 504 | 434 |
| 505 /** | 435 /** |
| 506 * Adds a field specifying the application ID to this log entry. | 436 * Adds a field specifying the application ID to this log entry. |
| 507 * @return {void} Nothing. | 437 * @return {void} Nothing. |
| 508 */ | 438 */ |
| 509 remoting.ServerLogEntry.prototype.addApplicationId = function() { | 439 remoting.ServerLogEntry.prototype.addApplicationId = function() { |
| 510 this.set_(remoting.ServerLogEntry.KEY_APP_ID_, chrome.runtime.id); | 440 this.set_(remoting.ServerLogEntry.KEY_APP_ID_, chrome.runtime.id); |
| 511 }; | 441 }; |
| 512 | 442 |
| OLD | NEW |