Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Utils provide logging functions and other JS functions commonly used by the | 5 // Utils provide logging functions and other JS functions commonly used by the |
| 6 // app and media players. | 6 // app and media players. |
| 7 var Utils = new function() { | 7 var Utils = new function() { |
| 8 this.titleChanged = false; | 8 this.titleChanged = false; |
| 9 }; | 9 }; |
| 10 | 10 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 var message = String.fromCharCode.apply(null, msg); | 195 var message = String.fromCharCode.apply(null, msg); |
| 196 return message.substring(0, prefix.length) == prefix; | 196 return message.substring(0, prefix.length) == prefix; |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 Utils.installTitleEventHandler = function(element, event) { | 199 Utils.installTitleEventHandler = function(element, event) { |
| 200 element.addEventListener(event, function(e) { | 200 element.addEventListener(event, function(e) { |
| 201 Utils.setResultInTitle(e.type); | 201 Utils.setResultInTitle(e.type); |
| 202 }, false); | 202 }, false); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 Utils.isHeartBeatMessage = function(msg) { | 205 Utils.isHeartBeatMessage = function(message) { |
| 206 if (message.messageType == 'license-renewal') { | |
|
ddorwin
2015/01/14 23:24:52
nit: Unless the rest of the code follows this patt
jrummell
2015/01/15 01:32:56
Done.
| |
| 207 if (!Utils.isHeartBeatMessagePrefixed(message.message)) { | |
| 208 Utils.failTest( | |
| 209 'license-renewal message doesn\'t contain HEART_BEAT_HEADER', | |
| 210 KEY_ERROR); | |
| 211 } | |
| 212 return true; | |
| 213 } | |
| 214 return false; | |
| 215 }; | |
| 216 | |
| 217 Utils.isHeartBeatMessagePrefixed = function(msg) { | |
| 206 return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER); | 218 return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER); |
| 207 }; | 219 }; |
| 208 | 220 |
| 209 Utils.resetTitleChange = function() { | 221 Utils.resetTitleChange = function() { |
| 210 this.titleChanged = false; | 222 this.titleChanged = false; |
| 211 document.title = ''; | 223 document.title = ''; |
| 212 }; | 224 }; |
| 213 | 225 |
| 214 Utils.sendRequest = function(requestType, responseType, message, serverURL, | 226 Utils.sendRequest = function(requestType, responseType, message, serverURL, |
| 215 onSuccessCallbackFn, forceInvalidResponse) { | 227 onSuccessCallbackFn, forceInvalidResponse) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 var time = Utils.getCurrentTimeString(); | 287 var time = Utils.getCurrentTimeString(); |
| 276 // Log to document. | 288 // Log to document. |
| 277 Utils.documentLog(arguments[0], time); | 289 Utils.documentLog(arguments[0], time); |
| 278 // Log to JS console. | 290 // Log to JS console. |
| 279 var logString = time + ' - '; | 291 var logString = time + ' - '; |
| 280 for (var i = 0; i < arguments.length; i++) { | 292 for (var i = 0; i < arguments.length; i++) { |
| 281 logString += ' ' + arguments[i]; | 293 logString += ' ' + arguments[i]; |
| 282 } | 294 } |
| 283 console.log(logString); | 295 console.log(logString); |
| 284 }; | 296 }; |
| OLD | NEW |