| 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 * 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.prototype.KEY_EVENT_NAME_ = 'event-name'; | 24 remoting.ServerLogEntry.KEY_EVENT_NAME_ = 'event-name'; |
| 25 /** @private */ | 25 /** @private */ |
| 26 remoting.ServerLogEntry.prototype.VALUE_EVENT_NAME_SESSION_STATE_ = | 26 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_ = |
| 27 'session-state'; | 27 'session-state'; |
| 28 | 28 |
| 29 /** @private */ | 29 /** @private */ |
| 30 remoting.ServerLogEntry.prototype.KEY_ID_ = 'id'; | 30 remoting.ServerLogEntry.KEY_ID_ = 'id'; |
| 31 | 31 |
| 32 /** @private */ | 32 /** @private */ |
| 33 remoting.ServerLogEntry.prototype.KEY_ROLE_ = 'role'; | 33 remoting.ServerLogEntry.KEY_ROLE_ = 'role'; |
| 34 /** @private */ | 34 /** @private */ |
| 35 remoting.ServerLogEntry.prototype.VALUE_ROLE_CLIENT_ = 'client'; | 35 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_ = 'client'; |
| 36 | 36 |
| 37 /** @private */ | 37 /** @private */ |
| 38 remoting.ServerLogEntry.prototype.KEY_SESSION_STATE_ = 'session-state'; | 38 remoting.ServerLogEntry.KEY_SESSION_STATE_ = 'session-state'; |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * @private | 41 * @private |
| 42 * @param {remoting.ClientSession.State} state | 42 * @param {remoting.ClientSession.State} state |
| 43 * @return {string} | 43 * @return {string} |
| 44 */ | 44 */ |
| 45 remoting.ServerLogEntry.prototype.getValueForSessionState = function(state) { | 45 remoting.ServerLogEntry.getValueForSessionState = function(state) { |
| 46 switch(state) { | 46 switch(state) { |
| 47 case remoting.ClientSession.State.UNKNOWN: | 47 case remoting.ClientSession.State.UNKNOWN: |
| 48 return 'unknown'; | 48 return 'unknown'; |
| 49 case remoting.ClientSession.State.CREATED: | 49 case remoting.ClientSession.State.CREATED: |
| 50 return 'created'; | 50 return 'created'; |
| 51 case remoting.ClientSession.State.BAD_PLUGIN_VERSION: | 51 case remoting.ClientSession.State.BAD_PLUGIN_VERSION: |
| 52 return 'bad-plugin-version'; | 52 return 'bad-plugin-version'; |
| 53 case remoting.ClientSession.State.UNKNOWN_PLUGIN_ERROR: | 53 case remoting.ClientSession.State.UNKNOWN_PLUGIN_ERROR: |
| 54 return 'unknown-plugin-error'; | 54 return 'unknown-plugin-error'; |
| 55 case remoting.ClientSession.State.CONNECTING: | 55 case remoting.ClientSession.State.CONNECTING: |
| 56 return 'connecting'; | 56 return 'connecting'; |
| 57 case remoting.ClientSession.State.INITIALIZING: | 57 case remoting.ClientSession.State.INITIALIZING: |
| 58 return 'initializing'; | 58 return 'initializing'; |
| 59 case remoting.ClientSession.State.CONNECTED: | 59 case remoting.ClientSession.State.CONNECTED: |
| 60 return 'connected'; | 60 return 'connected'; |
| 61 case remoting.ClientSession.State.CLOSED: | 61 case remoting.ClientSession.State.CLOSED: |
| 62 return 'closed'; | 62 return 'closed'; |
| 63 case remoting.ClientSession.State.CONNECTION_FAILED: | 63 case remoting.ClientSession.State.CONNECTION_FAILED: |
| 64 return 'connection-failed'; | 64 return 'connection-failed'; |
| 65 default: | 65 default: |
| 66 return 'undefined-' + state; | 66 return 'undefined-' + state; |
| 67 } | 67 } |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 /** @private */ | 70 /** @private */ |
| 71 remoting.ServerLogEntry.prototype.KEY_CONNECTION_ERROR_ = 'connection-error'; | 71 remoting.ServerLogEntry.KEY_CONNECTION_ERROR_ = 'connection-error'; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @private | 74 * @private |
| 75 * @param {remoting.ClientSession.ConnectionError} connectionError | 75 * @param {remoting.ClientSession.ConnectionError} connectionError |
| 76 * @return {string} | 76 * @return {string} |
| 77 */ | 77 */ |
| 78 remoting.ServerLogEntry.prototype.getValueForConnectionError = | 78 remoting.ServerLogEntry.getValueForConnectionError = |
| 79 function(connectionError) { | 79 function(connectionError) { |
| 80 switch(connectionError) { | 80 switch(connectionError) { |
| 81 case remoting.ClientSession.ConnectionError.NONE: | 81 case remoting.ClientSession.ConnectionError.NONE: |
| 82 return 'none'; | 82 return 'none'; |
| 83 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: | 83 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: |
| 84 return 'host-is-offline'; | 84 return 'host-is-offline'; |
| 85 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: | 85 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: |
| 86 return 'session-rejected'; | 86 return 'session-rejected'; |
| 87 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: | 87 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: |
| 88 return 'incompatible-protocol'; | 88 return 'incompatible-protocol'; |
| 89 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE: | 89 case remoting.ClientSession.ConnectionError.NETWORK_FAILURE: |
| 90 return 'network-failure'; | 90 return 'network-failure'; |
| 91 default: | 91 default: |
| 92 return 'unknown-' + connectionError; | 92 return 'unknown-' + connectionError; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** @private */ | 96 /** @private */ |
| 97 remoting.ServerLogEntry.prototype.KEY_OS_NAME_ = 'os-name'; | 97 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_ = |
| 98 "connection-statistics"; |
| 98 /** @private */ | 99 /** @private */ |
| 99 remoting.ServerLogEntry.prototype.VALUE_OS_NAME_WINDOWS_ = 'Windows'; | 100 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_ = "video-bandwidth"; |
| 100 /** @private */ | 101 /** @private */ |
| 101 remoting.ServerLogEntry.prototype.VALUE_OS_NAME_LINUX_ = 'Linux'; | 102 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_ = "capture-latency"; |
| 102 /** @private */ | 103 /** @private */ |
| 103 remoting.ServerLogEntry.prototype.VALUE_OS_NAME_MAC_ = 'Mac'; | 104 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_ = "encode-latency"; |
| 104 /** @private */ | 105 /** @private */ |
| 105 remoting.ServerLogEntry.prototype.VALUE_OS_NAME_CHROMEOS_ = 'ChromeOS'; | 106 remoting.ServerLogEntry.KEY_DECODE_LATENCY_ = "decode-latency"; |
| 107 /** @private */ |
| 108 remoting.ServerLogEntry.KEY_RENDER_LATENCY_ = "render-latency"; |
| 109 /** @private */ |
| 110 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_ = "roundtrip-latency"; |
| 106 | 111 |
| 107 /** @private */ | 112 /** @private */ |
| 108 remoting.ServerLogEntry.prototype.KEY_OS_VERSION_ = 'os-version'; | 113 remoting.ServerLogEntry.KEY_OS_NAME_ = 'os-name'; |
| 114 /** @private */ |
| 115 remoting.ServerLogEntry.VALUE_OS_NAME_WINDOWS_ = 'Windows'; |
| 116 /** @private */ |
| 117 remoting.ServerLogEntry.VALUE_OS_NAME_LINUX_ = 'Linux'; |
| 118 /** @private */ |
| 119 remoting.ServerLogEntry.VALUE_OS_NAME_MAC_ = 'Mac'; |
| 120 /** @private */ |
| 121 remoting.ServerLogEntry.VALUE_OS_NAME_CHROMEOS_ = 'ChromeOS'; |
| 109 | 122 |
| 110 /** @private */ | 123 /** @private */ |
| 111 remoting.ServerLogEntry.prototype.KEY_CPU_ = 'cpu'; | 124 remoting.ServerLogEntry.KEY_OS_VERSION_ = 'os-version'; |
| 112 | 125 |
| 113 /** @private */ | 126 /** @private */ |
| 114 remoting.ServerLogEntry.prototype.KEY_BROWSER_VERSION_ = 'browser-version'; | 127 remoting.ServerLogEntry.KEY_CPU_ = 'cpu'; |
| 115 | 128 |
| 116 /** @private */ | 129 /** @private */ |
| 117 remoting.ServerLogEntry.prototype.KEY_WEBAPP_VERSION_ = 'webapp-version'; | 130 remoting.ServerLogEntry.KEY_BROWSER_VERSION_ = 'browser-version'; |
| 131 |
| 132 /** @private */ |
| 133 remoting.ServerLogEntry.KEY_WEBAPP_VERSION_ = 'webapp-version'; |
| 118 | 134 |
| 119 /** | 135 /** |
| 120 * Sets one field in this log entry. | 136 * Sets one field in this log entry. |
| 121 * | 137 * |
| 122 * @private | 138 * @private |
| 123 * @param {string} key | 139 * @param {string} key |
| 124 * @param {string} value | 140 * @param {string} value |
| 125 */ | 141 */ |
| 126 remoting.ServerLogEntry.prototype.set = function(key, value) { | 142 remoting.ServerLogEntry.prototype.set = function(key, value) { |
| 127 this.dict[key] = value; | 143 this.dict[key] = value; |
| 128 }; | 144 }; |
| 129 | 145 |
| 130 /** | 146 /** |
| 131 * Converts this object into an XML stanza. | 147 * Converts this object into an XML stanza. |
| 132 * | 148 * |
| 133 * @return {string} | 149 * @return {string} |
| 134 */ | 150 */ |
| 135 remoting.ServerLogEntry.prototype.toStanza = function() { | 151 remoting.ServerLogEntry.prototype.toStanza = function() { |
| 136 var stanza = '<gr:entry '; | 152 var stanza = '<gr:entry '; |
| 137 for (var key in this.dict) { | 153 for (var key in this.dict) { |
| 138 stanza += escape(key) + '="' + escape(this.dict[key]) + '" '; | 154 stanza += escape(key) + '="' + escape(this.dict[key]) + '" '; |
| 139 } | 155 } |
| 140 stanza += '/>'; | 156 stanza += '/>'; |
| 141 return stanza; | 157 return stanza; |
| 142 }; | 158 }; |
| 143 | 159 |
| 144 /** | 160 /** |
| 161 * Prints this object on the debug log. |
| 162 * |
| 163 * @param {number} indentLevel the indentation level |
| 164 */ |
| 165 remoting.ServerLogEntry.prototype.toDebugLog = function(indentLevel) { |
| 166 /** @type Array.<string> */ var fields = []; |
| 167 for (var key in this.dict) { |
| 168 fields.push(key + ': ' + this.dict[key]); |
| 169 } |
| 170 remoting.debug.logIndent(indentLevel, fields.join(', ')); |
| 171 }; |
| 172 |
| 173 /** |
| 145 * Makes a log entry for a change of client session state. | 174 * Makes a log entry for a change of client session state. |
| 146 * | 175 * |
| 147 * @param {remoting.ClientSession.State} state | 176 * @param {remoting.ClientSession.State} state |
| 148 * @param {remoting.ClientSession.ConnectionError} connectionError | 177 * @param {remoting.ClientSession.ConnectionError} connectionError |
| 149 * @return {remoting.ServerLogEntry} | 178 * @return {remoting.ServerLogEntry} |
| 150 */ | 179 */ |
| 151 remoting.ServerLogEntry.prototype.makeClientSessionStateChange = | 180 remoting.ServerLogEntry.makeClientSessionStateChange = function(state, |
| 152 function(state, connectionError) { | 181 connectionError) { |
| 153 var entry = new remoting.ServerLogEntry(); | 182 var entry = new remoting.ServerLogEntry(); |
| 154 entry.set(this.KEY_ROLE_, this.VALUE_ROLE_CLIENT_); | 183 entry.set(remoting.ServerLogEntry.KEY_ROLE_, |
| 155 entry.set(this.KEY_EVENT_NAME_, this.VALUE_EVENT_NAME_SESSION_STATE_); | 184 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 156 entry.set(this.KEY_SESSION_STATE_, this.getValueForSessionState(state)); | 185 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 186 remoting.ServerLogEntry.VALUE_EVENT_NAME_SESSION_STATE_); |
| 187 entry.set(remoting.ServerLogEntry.KEY_SESSION_STATE_, |
| 188 remoting.ServerLogEntry.getValueForSessionState(state)); |
| 157 if (connectionError != remoting.ClientSession.ConnectionError.NONE) { | 189 if (connectionError != remoting.ClientSession.ConnectionError.NONE) { |
| 158 entry.set(this.KEY_CONNECTION_ERROR_, | 190 entry.set(remoting.ServerLogEntry.KEY_CONNECTION_ERROR_, |
| 159 this.getValueForConnectionError(connectionError)); | 191 remoting.ServerLogEntry.getValueForConnectionError( |
| 192 connectionError)); |
| 160 } | 193 } |
| 161 return entry; | 194 return entry; |
| 162 }; | 195 }; |
| 163 | 196 |
| 164 /** | 197 /** |
| 198 * Makes a log entry for a set of connection statistics. |
| 199 * Returns null if all the statistics were zero. |
| 200 * |
| 201 * @param {remoting.StatsAccumulator} statsAccumulator |
| 202 * @return {?remoting.ServerLogEntry} |
| 203 */ |
| 204 remoting.ServerLogEntry.makeStats = function(statsAccumulator) { |
| 205 var entry = new remoting.ServerLogEntry(); |
| 206 entry.set(remoting.ServerLogEntry.KEY_ROLE_, |
| 207 remoting.ServerLogEntry.VALUE_ROLE_CLIENT_); |
| 208 entry.set(remoting.ServerLogEntry.KEY_EVENT_NAME_, |
| 209 remoting.ServerLogEntry.VALUE_EVENT_NAME_CONNECTION_STATISTICS_); |
| 210 var nonZero = false; |
| 211 nonZero |= entry.addStatsField( |
| 212 remoting.ServerLogEntry.KEY_VIDEO_BANDWIDTH_, |
| 213 remoting.ClientSession.STATS_KEY_VIDEO_BANDWIDTH, statsAccumulator); |
| 214 nonZero |= entry.addStatsField( |
| 215 remoting.ServerLogEntry.KEY_CAPTURE_LATENCY_, |
| 216 remoting.ClientSession.STATS_KEY_CAPTURE_LATENCY, statsAccumulator); |
| 217 nonZero |= entry.addStatsField( |
| 218 remoting.ServerLogEntry.KEY_ENCODE_LATENCY_, |
| 219 remoting.ClientSession.STATS_KEY_ENCODE_LATENCY, statsAccumulator); |
| 220 nonZero |= entry.addStatsField( |
| 221 remoting.ServerLogEntry.KEY_DECODE_LATENCY_, |
| 222 remoting.ClientSession.STATS_KEY_DECODE_LATENCY, statsAccumulator); |
| 223 nonZero |= entry.addStatsField( |
| 224 remoting.ServerLogEntry.KEY_RENDER_LATENCY_, |
| 225 remoting.ClientSession.STATS_KEY_RENDER_LATENCY, statsAccumulator); |
| 226 nonZero |= entry.addStatsField( |
| 227 remoting.ServerLogEntry.KEY_ROUNDTRIP_LATENCY_, |
| 228 remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY, statsAccumulator); |
| 229 if (nonZero) { |
| 230 return entry; |
| 231 } |
| 232 return null; |
| 233 }; |
| 234 |
| 235 /** |
| 236 * Adds one connection statistic to a log entry. |
| 237 * |
| 238 * @private |
| 239 * @param {string} entryKey |
| 240 * @param {string} statsKey |
| 241 * @param {remoting.StatsAccumulator} statsAccumulator |
| 242 * @return {boolean} whether the statistic is non-zero |
| 243 */ |
| 244 remoting.ServerLogEntry.prototype.addStatsField = function( |
| 245 entryKey, statsKey, statsAccumulator) { |
| 246 var val = statsAccumulator.calcMean(statsKey); |
| 247 this.set(entryKey, val.toString()); |
| 248 return (val != 0); |
| 249 }; |
| 250 |
| 251 /** |
| 165 * Adds an ID field to this log entry. | 252 * Adds an ID field to this log entry. |
| 166 * | 253 * |
| 167 * @param {string} id | 254 * @param {string} id |
| 168 */ | 255 */ |
| 169 remoting.ServerLogEntry.prototype.addIdField = function(id) { | 256 remoting.ServerLogEntry.prototype.addIdField = function(id) { |
| 170 this.set(this.KEY_ID_, id); | 257 this.set(remoting.ServerLogEntry.KEY_ID_, id); |
| 171 } | 258 } |
| 172 | 259 |
| 173 /** | 260 /** |
| 174 * Adds fields describing the host to this log entry. | 261 * Adds fields describing the host to this log entry. |
| 175 */ | 262 */ |
| 176 remoting.ServerLogEntry.prototype.addHostFields = function() { | 263 remoting.ServerLogEntry.prototype.addHostFields = function() { |
| 177 var host = this.getHostData(); | 264 var host = remoting.ServerLogEntry.getHostData(); |
| 178 if (host) { | 265 if (host) { |
| 179 if (host.os_name.length > 0) { | 266 if (host.os_name.length > 0) { |
| 180 this.set(this.KEY_OS_NAME_, host.os_name); | 267 this.set(remoting.ServerLogEntry.KEY_OS_NAME_, host.os_name); |
| 181 } | 268 } |
| 182 if (host.os_version.length > 0) { | 269 if (host.os_version.length > 0) { |
| 183 this.set(this.KEY_OS_VERSION_, host.os_version); | 270 this.set(remoting.ServerLogEntry.KEY_OS_VERSION_, host.os_version); |
| 184 } | 271 } |
| 185 if (host.cpu.length > 0) { | 272 if (host.cpu.length > 0) { |
| 186 this.set(this.KEY_CPU_, host.cpu); | 273 this.set(remoting.ServerLogEntry.KEY_CPU_, host.cpu); |
| 187 } | 274 } |
| 188 } | 275 } |
| 189 }; | 276 }; |
| 190 | 277 |
| 191 /** | 278 /** |
| 192 * Extracts host data from the userAgent string. | 279 * Extracts host data from the userAgent string. |
| 193 * | 280 * |
| 194 * @private | 281 * @private |
| 195 * @return {{os_name:string, os_version:string, cpu:string} | null} | 282 * @return {{os_name:string, os_version:string, cpu:string} | null} |
| 196 */ | 283 */ |
| 197 remoting.ServerLogEntry.prototype.getHostData = function() { | 284 remoting.ServerLogEntry.getHostData = function() { |
| 198 return this.extractHostDataFrom(navigator.userAgent); | 285 return remoting.ServerLogEntry.extractHostDataFrom(navigator.userAgent); |
| 199 }; | 286 }; |
| 200 | 287 |
| 201 /** | 288 /** |
| 202 * Extracts host data from the given userAgent string. | 289 * Extracts host data from the given userAgent string. |
| 203 * | 290 * |
| 204 * @private | 291 * @private |
| 205 * @param {string} s | 292 * @param {string} s |
| 206 * @return {{os_name:string, os_version:string, cpu:string} | null} | 293 * @return {{os_name:string, os_version:string, cpu:string} | null} |
| 207 */ | 294 */ |
| 208 remoting.ServerLogEntry.prototype.extractHostDataFrom = function(s) { | 295 remoting.ServerLogEntry.extractHostDataFrom = function(s) { |
| 209 // Sample userAgent strings: | 296 // Sample userAgent strings: |
| 210 // 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 ' + | 297 // 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 ' + |
| 211 // '(KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2' | 298 // '(KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2' |
| 212 // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 ' + | 299 // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.8 ' + |
| 213 // '(KHTML, like Gecko) Chrome/17.0.933.0 Safari/535.8' | 300 // '(KHTML, like Gecko) Chrome/17.0.933.0 Safari/535.8' |
| 214 // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 ' + | 301 // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 ' + |
| 215 // '(KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' | 302 // '(KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' |
| 216 // 'Mozilla/5.0 (X11; CrOS i686 14.811.154) AppleWebKit/535.1 ' + | 303 // 'Mozilla/5.0 (X11; CrOS i686 14.811.154) AppleWebKit/535.1 ' + |
| 217 // '(KHTML, like Gecko) Chrome/14.0.835.204 Safari/535.1' | 304 // '(KHTML, like Gecko) Chrome/14.0.835.204 Safari/535.1' |
| 218 var match = new RegExp('Windows NT ([0-9\\.]*)').exec(s); | 305 var match = new RegExp('Windows NT ([0-9\\.]*)').exec(s); |
| 219 if (match && (match.length >= 2)) { | 306 if (match && (match.length >= 2)) { |
| 220 return { | 307 return { |
| 221 'os_name': this.VALUE_OS_NAME_WINDOWS_, | 308 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_WINDOWS_, |
| 222 'os_version': match[1], | 309 'os_version': match[1], |
| 223 'cpu': '' | 310 'cpu': '' |
| 224 }; | 311 }; |
| 225 } | 312 } |
| 226 match = new RegExp('Linux ([a-zA-Z0-9_]*)').exec(s); | 313 match = new RegExp('Linux ([a-zA-Z0-9_]*)').exec(s); |
| 227 if (match && (match.length >= 2)) { | 314 if (match && (match.length >= 2)) { |
| 228 return { | 315 return { |
| 229 'os_name': this.VALUE_OS_NAME_LINUX_, | 316 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_LINUX_, |
| 230 'os_version' : '', | 317 'os_version' : '', |
| 231 'cpu': match[1] | 318 'cpu': match[1] |
| 232 }; | 319 }; |
| 233 } | 320 } |
| 234 match = new RegExp('([a-zA-Z]*) Mac OS X ([0-9_]*)').exec(s); | 321 match = new RegExp('([a-zA-Z]*) Mac OS X ([0-9_]*)').exec(s); |
| 235 if (match && (match.length >= 3)) { | 322 if (match && (match.length >= 3)) { |
| 236 return { | 323 return { |
| 237 'os_name': this.VALUE_OS_NAME_MAC_, | 324 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_MAC_, |
| 238 'os_version': match[2].replace(/_/g, '.'), | 325 'os_version': match[2].replace(/_/g, '.'), |
| 239 'cpu': match[1] | 326 'cpu': match[1] |
| 240 }; | 327 }; |
| 241 } | 328 } |
| 242 match = new RegExp('CrOS ([a-zA-Z0-9]*) ([0-9.]*)').exec(s); | 329 match = new RegExp('CrOS ([a-zA-Z0-9]*) ([0-9.]*)').exec(s); |
| 243 if (match && (match.length >= 3)) { | 330 if (match && (match.length >= 3)) { |
| 244 return { | 331 return { |
| 245 'os_name': this.VALUE_OS_NAME_CHROMEOS_, | 332 'os_name': remoting.ServerLogEntry.VALUE_OS_NAME_CHROMEOS_, |
| 246 'os_version': match[2], | 333 'os_version': match[2], |
| 247 'cpu': match[1] | 334 'cpu': match[1] |
| 248 }; | 335 }; |
| 249 } | 336 } |
| 250 return null; | 337 return null; |
| 251 }; | 338 }; |
| 252 | 339 |
| 253 /** | 340 /** |
| 254 * Adds a field specifying the browser version to this log entry. | 341 * Adds a field specifying the browser version to this log entry. |
| 255 */ | 342 */ |
| 256 remoting.ServerLogEntry.prototype.addChromeVersionField = function() { | 343 remoting.ServerLogEntry.prototype.addChromeVersionField = function() { |
| 257 var version = this.getChromeVersion(); | 344 var version = remoting.ServerLogEntry.getChromeVersion(); |
| 258 if (version != null) { | 345 if (version != null) { |
| 259 this.set(this.KEY_BROWSER_VERSION_, version); | 346 this.set(remoting.ServerLogEntry.KEY_BROWSER_VERSION_, version); |
| 260 } | 347 } |
| 261 }; | 348 }; |
| 262 | 349 |
| 263 /** | 350 /** |
| 264 * Extracts the Chrome version from the userAgent string. | 351 * Extracts the Chrome version from the userAgent string. |
| 265 * | 352 * |
| 266 * @private | 353 * @private |
| 267 * @return {string | null} | 354 * @return {string | null} |
| 268 */ | 355 */ |
| 269 remoting.ServerLogEntry.prototype.getChromeVersion = function() { | 356 remoting.ServerLogEntry.getChromeVersion = function() { |
| 270 return this.extractChromeVersionFrom(navigator.userAgent); | 357 return remoting.ServerLogEntry.extractChromeVersionFrom(navigator.userAgent); |
| 271 }; | 358 }; |
| 272 | 359 |
| 273 /** | 360 /** |
| 274 * Extracts the Chrome version from the given userAgent string. | 361 * Extracts the Chrome version from the given userAgent string. |
| 275 * | 362 * |
| 276 * @private | 363 * @private |
| 277 * @param {string} s | 364 * @param {string} s |
| 278 * @return {string | null} | 365 * @return {string | null} |
| 279 */ | 366 */ |
| 280 remoting.ServerLogEntry.prototype.extractChromeVersionFrom = function(s) { | 367 remoting.ServerLogEntry.extractChromeVersionFrom = function(s) { |
| 281 var match = new RegExp('Chrome/([0-9.]*)').exec(s); | 368 var match = new RegExp('Chrome/([0-9.]*)').exec(s); |
| 282 if (match && (match.length >= 2)) { | 369 if (match && (match.length >= 2)) { |
| 283 return match[1]; | 370 return match[1]; |
| 284 } | 371 } |
| 285 return null; | 372 return null; |
| 286 }; | 373 }; |
| 287 | 374 |
| 288 /** | 375 /** |
| 289 * Adds a field specifying the webapp version to this log entry. | 376 * Adds a field specifying the webapp version to this log entry. |
| 290 */ | 377 */ |
| 291 remoting.ServerLogEntry.prototype.addWebappVersionField = function() { | 378 remoting.ServerLogEntry.prototype.addWebappVersionField = function() { |
| 292 this.set(this.KEY_WEBAPP_VERSION_, chrome.app.getDetails().version); | 379 this.set(remoting.ServerLogEntry.KEY_WEBAPP_VERSION_, |
| 380 chrome.app.getDetails().version); |
| 293 }; | 381 }; |
| OLD | NEW |