Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: extensions/renderer/resources/media_router_bindings.js

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 var mediaRouter; 5 var mediaRouter;
6 6
7 define('media_router_bindings', [ 7 define('media_router_bindings', [
8 'mojo/public/js/bindings', 8 'mojo/public/js/bindings',
9 'mojo/public/js/core', 9 'mojo/public/js/core',
10 'content/public/renderer/service_provider', 10 'content/public/renderer/service_provider',
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 /** 58 /**
59 * Converts a route message to a RouteMessage Mojo object. 59 * Converts a route message to a RouteMessage Mojo object.
60 * @param {!RouteMessage} message 60 * @param {!RouteMessage} message
61 * @return {!mediaRouterMojom.RouteMessage} A Mojo RouteMessage object. 61 * @return {!mediaRouterMojom.RouteMessage} A Mojo RouteMessage object.
62 */ 62 */
63 function messageToMojo_(message) { 63 function messageToMojo_(message) {
64 if ("string" == typeof message.message) { 64 if ("string" == typeof message.message) {
65 return new mediaRouterMojom.RouteMessage({ 65 return new mediaRouterMojom.RouteMessage({
66 'route_id': message.routeId,
67 'type': mediaRouterMojom.RouteMessage.Type.TEXT, 66 'type': mediaRouterMojom.RouteMessage.Type.TEXT,
68 'message': message.message, 67 'message': message.message,
69 }); 68 });
70 } else { 69 } else {
71 return new mediaRouterMojom.RouteMessage({ 70 return new mediaRouterMojom.RouteMessage({
72 'route_id': message.routeId,
73 'type': mediaRouterMojom.RouteMessage.Type.BINARY, 71 'type': mediaRouterMojom.RouteMessage.Type.BINARY,
74 'data': message.message, 72 'data': message.message,
75 }); 73 });
76 } 74 }
77 } 75 }
78 76
79 /** 77 /**
80 * Creates a new MediaRouter. 78 * Creates a new MediaRouter.
81 * Converts a route struct to its Mojo form. 79 * Converts a route struct to its Mojo form.
82 * @param {!MediaRouterService} service 80 * @param {!MediaRouterService} service
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 * @type {function(string, string): Promise} 313 * @type {function(string, string): Promise}
316 */ 314 */
317 this.sendRouteMessage = null; 315 this.sendRouteMessage = null;
318 316
319 /** 317 /**
320 * @type {function(string, Uint8Array): Promise} 318 * @type {function(string, Uint8Array): Promise}
321 */ 319 */
322 this.sendRouteBinaryMessage = null; 320 this.sendRouteBinaryMessage = null;
323 321
324 /** 322 /**
325 * @type {function(Array.<string>): Promise.<Array.<RouteMessage>>} 323 * @type {function(string): Promise.<Array.<RouteMessage>>}
326 */ 324 */
327 this.listenForRouteMessages = null; 325 this.listenForRouteMessages = null;
328 326
329 /** 327 /**
330 * @type {function()} 328 * @type {function()}
331 */ 329 */
332 this.startObservingMediaRoutes = null; 330 this.startObservingMediaRoutes = null;
333 331
334 /** 332 /**
335 * @type {function()} 333 * @type {function()}
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 return this.handlers_.sendRouteBinaryMessage(routeId, data) 495 return this.handlers_.sendRouteBinaryMessage(routeId, data)
498 .then(function() { 496 .then(function() {
499 return {'sent': true}; 497 return {'sent': true};
500 }, function() { 498 }, function() {
501 return {'sent': false}; 499 return {'sent': false};
502 }); 500 });
503 }; 501 };
504 502
505 /** 503 /**
506 * Listen for next batch of messages from one of the routeIds. 504 * Listen for next batch of messages from one of the routeIds.
507 * @param {!Array.<string>} routeIds 505 * @param {!string} routeId
508 * @return {!Promise.<Array.<RouteMessage>>} Resolved with a list of messages, 506 * @return {!Promise.<Array.<RouteMessage>>} Resolved with a list of messages,
509 * an empty list if an error occurred. 507 * an empty list if an error occurred.
510 */ 508 */
511 MediaRouteProvider.prototype.listenForRouteMessages = function(routeIds) { 509 MediaRouteProvider.prototype.listenForRouteMessages = function(routeId) {
mark a. foltz 2015/08/04 23:47:02 This looks like a breaking change. Don't you need
imcheng 2015/08/05 21:38:35 We are still sending an array to the extension so
512 return this.handlers_.listenForRouteMessages(routeIds) 510 return this.handlers_.listenForRouteMessages([routeId])
513 .then(function(messages) { 511 .then(function(messages) {
514 return {'messages': messages.map(messageToMojo_)}; 512 return {'messages': messages.map(messageToMojo_)};
515 }, function() { 513 }, function() {
516 return {'messages': []}; 514 return {'messages': []};
517 }); 515 });
518 }; 516 };
519 517
520 /** 518 /**
521 * Requests that the provider manager start sending information about active 519 * Requests that the provider manager start sending information about active
522 * media routes to the Media Router. 520 * media routes to the Media Router.
(...skipping 11 matching lines...) Expand all
534 }; 532 };
535 533
536 mediaRouter = new MediaRouter(connector.bindHandleToProxy( 534 mediaRouter = new MediaRouter(connector.bindHandleToProxy(
537 serviceProvider.connectToService( 535 serviceProvider.connectToService(
538 mediaRouterMojom.MediaRouter.name), 536 mediaRouterMojom.MediaRouter.name),
539 mediaRouterMojom.MediaRouter)); 537 mediaRouterMojom.MediaRouter));
540 538
541 return mediaRouter; 539 return mediaRouter;
542 }); 540 });
543 541
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698