Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 'chrome/common/media_router/mojo/media_controller.mojom', | 8 'chrome/common/media_router/mojo/media_controller.mojom', |
| 9 'chrome/common/media_router/mojo/media_router.mojom', | 9 'chrome/common/media_router/mojo/media_router.mojom', |
| 10 'chrome/common/media_router/mojo/media_status.mojom', | 10 'chrome/common/media_router/mojo/media_status.mojom', |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 * @type {function(string, string, !SinkSearchCriteria): string} | 558 * @type {function(string, string, !SinkSearchCriteria): string} |
| 559 */ | 559 */ |
| 560 this.searchSinks = null; | 560 this.searchSinks = null; |
| 561 | 561 |
| 562 /** | 562 /** |
| 563 * @type {function()} | 563 * @type {function()} |
| 564 */ | 564 */ |
| 565 this.provideSinks = null; | 565 this.provideSinks = null; |
| 566 | 566 |
| 567 /** | 567 /** |
| 568 * @type {function(string, !bindings.InterfaceRequest): !Promise<boolean>} | 568 * @type {function(string, !bindings.InterfaceRequest, |
| 569 * !mediaStatusMojom.MediaStatusObserverPtr): !Promise<boolean>} | |
| 569 */ | 570 */ |
| 570 this.createMediaRouteController = null; | 571 this.createMediaRouteController = null; |
| 571 | |
| 572 /** | |
| 573 * @type {function(string, !mediaStatusMojom.MediaStatusObserverPtr)} | |
| 574 */ | |
| 575 this.setMediaRouteStatusObserver = null; | |
| 576 }; | 572 }; |
| 577 | 573 |
| 578 /** | 574 /** |
| 579 * Routes calls from Media Router to the provider manager extension. | 575 * Routes calls from Media Router to the provider manager extension. |
| 580 * Registered with the MediaRouter stub. | 576 * Registered with the MediaRouter stub. |
| 581 * @param {!MediaRouter} MediaRouter proxy to call into the | 577 * @param {!MediaRouter} MediaRouter proxy to call into the |
| 582 * Media Router mojo interface. | 578 * Media Router mojo interface. |
| 583 * @constructor | 579 * @constructor |
| 584 */ | 580 */ |
| 585 function MediaRouteProvider(mediaRouter) { | 581 function MediaRouteProvider(mediaRouter) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 'joinRoute', | 615 'joinRoute', |
| 620 'createRoute', | 616 'createRoute', |
| 621 'stopObservingMediaSinks', | 617 'stopObservingMediaSinks', |
| 622 'startObservingMediaRoutes', | 618 'startObservingMediaRoutes', |
| 623 'connectRouteByRouteId', | 619 'connectRouteByRouteId', |
| 624 'enableMdnsDiscovery', | 620 'enableMdnsDiscovery', |
| 625 'updateMediaSinks', | 621 'updateMediaSinks', |
| 626 'searchSinks', | 622 'searchSinks', |
| 627 'provideSinks', | 623 'provideSinks', |
| 628 'createMediaRouteController', | 624 'createMediaRouteController', |
| 629 'setMediaRouteStatusObserver', | |
| 630 'onBeforeInvokeHandler' | 625 'onBeforeInvokeHandler' |
| 631 ]; | 626 ]; |
| 632 requiredHandlers.forEach(function(nextHandler) { | 627 requiredHandlers.forEach(function(nextHandler) { |
| 633 if (handlers[nextHandler] === undefined) { | 628 if (handlers[nextHandler] === undefined) { |
| 634 console.error(nextHandler + ' handler not registered.'); | 629 console.error(nextHandler + ' handler not registered.'); |
| 635 } | 630 } |
| 636 }); | 631 }); |
| 637 } | 632 } |
| 638 | 633 |
| 639 /** | 634 /** |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 * @param {string} providerName | 907 * @param {string} providerName |
| 913 * @param {!Array<!mediaRouterMojom.MediaSink>} sinks | 908 * @param {!Array<!mediaRouterMojom.MediaSink>} sinks |
| 914 */ | 909 */ |
| 915 MediaRouteProvider.prototype.provideSinks = function(providerName, sinks) { | 910 MediaRouteProvider.prototype.provideSinks = function(providerName, sinks) { |
| 916 this.handlers_.onBeforeInvokeHandler(); | 911 this.handlers_.onBeforeInvokeHandler(); |
| 917 this.handlers_.provideSinks(providerName, sinks); | 912 this.handlers_.provideSinks(providerName, sinks); |
| 918 }; | 913 }; |
| 919 | 914 |
| 920 /** | 915 /** |
| 921 * Creates a controller for the given route and binds the given | 916 * Creates a controller for the given route and binds the given |
| 922 * InterfaceRequest to it. | 917 * InterfaceRequest to it, and registers an observer for media status updates |
| 918 * for the route. | |
| 923 * @param {string} routeId | 919 * @param {string} routeId |
| 924 * @param {!bindings.InterfaceRequest} controllerRequest | 920 * @param {!bindings.InterfaceRequest} controllerRequest |
| 921 * @param {!mediaStatusMojom.MediaStatusObserverPtr} observer | |
| 925 * @return {!Promise<!{success: boolean}>} Resolves to true if a controller | 922 * @return {!Promise<!{success: boolean}>} Resolves to true if a controller |
| 926 * is created. Resolves to false if a controller cannot be created, or if | 923 * is created. Resolves to false if a controller cannot be created, or if |
| 927 * the controller is already bound. | 924 * the controller is already bound. |
| 928 */ | 925 */ |
| 929 MediaRouteProvider.prototype.createMediaRouteController = function( | 926 MediaRouteProvider.prototype.createMediaRouteController = function( |
| 930 routeId, controllerRequest) { | 927 routeId, controllerRequest, observer) { |
| 931 // TODO(imcheng): Remove this check when M59 is in stable. | 928 // TODO(imcheng): Remove this check when M60 is in stable. |
| 932 if (!this.handlers_.createMediaRouteController) { | 929 if (!this.handlers_.createMediaRouteController) { |
| 933 return Promise.resolve({success: false}); | 930 return Promise.resolve({success: false}); |
| 934 } | 931 } |
| 935 | 932 |
| 936 this.handlers_.onBeforeInvokeHandler(); | 933 this.handlers_.onBeforeInvokeHandler(); |
| 937 this.handlers_.createMediaRouteController(routeId, controllerRequest) | 934 return this.handlers_ |
| 938 .then(controller => {success: true}, | 935 .createMediaRouteController(routeId, controllerRequest, observer) |
| 939 e => {success: false}); | 936 .then(controller => {success: true}, e => {success: false}); |
|
imcheng
2017/04/24 21:04:10
One more thing: let's make this return void for no
takumif
2017/04/24 21:26:24
Done.
| |
| 940 } | |
| 941 | |
| 942 /** | |
| 943 * Sets the MediaStatus oberver for a given route. MediaStatus updates are | |
| 944 * notified via the given observer interface. | |
| 945 * @param {string} routeId | |
| 946 * @param {!mediaStatusMojom.MediaStatusObserverPtr} observer | |
| 947 */ | |
| 948 MediaRouteProvider.prototype.setMediaRouteStatusObserver = function( | |
| 949 routeId, observer) { | |
| 950 // TODO(imcheng): Remove this check when M59 is in stable. | |
| 951 if (!this.handlers_.setMediaRouteStatusObserver) { | |
| 952 return; | |
| 953 } | |
| 954 this.handlers_.onBeforeInvokeHandler(); | |
| 955 this.handlers_.setMediaRouteStatusObserver(routeId, observer); | |
| 956 }; | 937 }; |
| 957 | 938 |
| 958 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( | 939 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( |
| 959 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); | 940 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); |
| 960 | 941 |
| 961 return mediaRouter; | 942 return mediaRouter; |
| 962 }); | 943 }); |
| OLD | NEW |