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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 * @param {string} providerName | 912 * @param {string} providerName |
| 913 * @param {!Array<!mediaRouterMojom.MediaSink>} sinks | 913 * @param {!Array<!mediaRouterMojom.MediaSink>} sinks |
| 914 */ | 914 */ |
| 915 MediaRouteProvider.prototype.provideSinks = function(providerName, sinks) { | 915 MediaRouteProvider.prototype.provideSinks = function(providerName, sinks) { |
| 916 this.handlers_.onBeforeInvokeHandler(); | 916 this.handlers_.onBeforeInvokeHandler(); |
| 917 this.handlers_.provideSinks(providerName, sinks); | 917 this.handlers_.provideSinks(providerName, sinks); |
| 918 }; | 918 }; |
| 919 | 919 |
| 920 /** | 920 /** |
| 921 * Creates a controller for the given route and binds the given | 921 * Creates a controller for the given route and binds the given |
| 922 * InterfaceRequest to it. | 922 * InterfaceRequest to it, and registers an observer for media status updates |
| 923 * for the route. | |
| 923 * @param {string} routeId | 924 * @param {string} routeId |
| 924 * @param {!bindings.InterfaceRequest} controllerRequest | 925 * @param {!bindings.InterfaceRequest} controllerRequest |
| 926 * @param {!mediaStatusMojom.MediaStatusObserverPtr} observer | |
| 925 * @return {!Promise<!{success: boolean}>} Resolves to true if a controller | 927 * @return {!Promise<!{success: boolean}>} Resolves to true if a controller |
| 926 * is created. Resolves to false if a controller cannot be created, or if | 928 * is created. Resolves to false if a controller cannot be created, or if |
| 927 * the controller is already bound. | 929 * the controller is already bound. |
| 928 */ | 930 */ |
| 929 MediaRouteProvider.prototype.createMediaRouteController = function( | 931 MediaRouteProvider.prototype.createMediaRouteController = function( |
| 930 routeId, controllerRequest) { | 932 routeId, controllerRequest, observer) { |
| 931 // TODO(imcheng): Remove this check when M59 is in stable. | 933 // TODO(imcheng): Remove this check when M59 is in stable. |
|
imcheng
2017/04/21 21:25:15
s/59/60
takumif
2017/04/21 23:01:11
Done.
| |
| 932 if (!this.handlers_.createMediaRouteController) { | 934 if (!this.handlers_.createMediaRouteController || |
|
imcheng
2017/04/21 21:25:15
It probably makes sense to use a combined API in t
takumif
2017/04/21 23:01:11
Done.
| |
| 935 !this.handlers_.setMediaRouteStatusObserver) { | |
| 933 return Promise.resolve({success: false}); | 936 return Promise.resolve({success: false}); |
| 934 } | 937 } |
| 935 | 938 |
| 936 this.handlers_.onBeforeInvokeHandler(); | 939 this.handlers_.onBeforeInvokeHandler(); |
| 937 this.handlers_.createMediaRouteController(routeId, controllerRequest) | 940 const result = |
| 938 .then(controller => {success: true}, | 941 this.handlers_.createMediaRouteController(routeId, controllerRequest) |
| 939 e => {success: false}); | 942 .then(controller => { |
| 940 } | 943 this.handlers_.setMediaRouteStatusObserver(routeId, |
| 941 | 944 observer); |
| 942 /** | 945 return {success: true}; |
| 943 * Sets the MediaStatus oberver for a given route. MediaStatus updates are | 946 }, |
| 944 * notified via the given observer interface. | 947 e => {success: false}); |
| 945 * @param {string} routeId | 948 return result; |
| 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 }; | 949 }; |
| 957 | 950 |
| 958 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( | 951 mediaRouter = new MediaRouter(new mediaRouterMojom.MediaRouterPtr( |
| 959 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); | 952 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name))); |
| 960 | 953 |
| 961 return mediaRouter; | 954 return mediaRouter; |
| 962 }); | 955 }); |
| OLD | NEW |