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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Interval for updating media info (in ms). | 8 * Interval for updating media info (in ms). |
9 * @type {number} | 9 * @type {number} |
10 * @const | 10 * @const |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 * @param {string} messageAsJson Content of message as json format. | 322 * @param {string} messageAsJson Content of message as json format. |
323 * @private | 323 * @private |
324 */ | 324 */ |
325 onMessage_: function(namespace, messageAsJson) { | 325 onMessage_: function(namespace, messageAsJson) { |
326 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) | 326 if (namespace !== CAST_MESSAGE_NAMESPACE || !messageAsJson) |
327 return; | 327 return; |
328 | 328 |
329 var message = JSON.parse(messageAsJson); | 329 var message = JSON.parse(messageAsJson); |
330 if (message['message'] === 'request-token') { | 330 if (message['message'] === 'request-token') { |
331 if (message['previousToken'] === this.token_) { | 331 if (message['previousToken'] === this.token_) { |
332 this.mediaManager_.getToken().then(function(token) { | 332 this.mediaManager_.getToken(true).then(function(token) { |
| 333 this.token_ = token; |
333 this.sendMessage_({message: 'push-token', token: token}); | 334 this.sendMessage_({message: 'push-token', token: token}); |
334 // TODO(yoshiki): Revokes the previous token. | 335 // TODO(yoshiki): Revokes the previous token. |
335 }.bind(this)).catch(function(error) { | 336 }.bind(this)).catch(function(error) { |
336 // Send an empty token as an error. | 337 // Send an empty token as an error. |
337 this.sendMessage_({message: 'push-token', token: ''}); | 338 this.sendMessage_({message: 'push-token', token: ''}); |
338 // TODO(yoshiki): Revokes the previous token. | 339 // TODO(yoshiki): Revokes the previous token. |
339 console.error(error.stack || error); | 340 console.error(error.stack || error); |
340 }); | 341 }); |
341 } else { | 342 } else { |
342 console.error( | 343 console.error( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 this.dispatchEvent(new Event('durationchange')); | 436 this.dispatchEvent(new Event('durationchange')); |
436 } | 437 } |
437 | 438 |
438 // Media is being unloaded. | 439 // Media is being unloaded. |
439 if (!alive) { | 440 if (!alive) { |
440 this.unloadMedia_(); | 441 this.unloadMedia_(); |
441 return; | 442 return; |
442 } | 443 } |
443 }, | 444 }, |
444 }; | 445 }; |
OLD | NEW |