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

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

Issue 2138013003: media::mojom::Remoter and CastRemotingConnector/Sender (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split-out some interfaces in prep for landing multi-part changes. Created 4 years, 5 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/frame_service_registry', 10 'content/public/renderer/frame_service_registry',
11 'chrome/browser/media/router/mojo/media_remoter.mojom',
11 'chrome/browser/media/router/mojo/media_router.mojom', 12 'chrome/browser/media/router/mojo/media_router.mojom',
12 'extensions/common/mojo/keep_alive.mojom', 13 'extensions/common/mojo/keep_alive.mojom',
13 'mojo/public/js/connection', 14 'mojo/public/js/connection',
14 'mojo/public/js/router', 15 'mojo/public/js/router',
15 ], function(bindings, 16 ], function(bindings,
16 core, 17 core,
17 serviceProvider, 18 serviceProvider,
19 mediaRemoterMojom,
18 mediaRouterMojom, 20 mediaRouterMojom,
19 keepAliveMojom, 21 keepAliveMojom,
20 connector, 22 connector,
21 routerModule) { 23 routerModule) {
22 'use strict'; 24 'use strict';
23 25
24 /** 26 /**
25 * Converts a media sink to a MediaSink Mojo object. 27 * Converts a media sink to a MediaSink Mojo object.
26 * @param {!MediaSink} sink A media sink. 28 * @param {!MediaSink} sink A media sink.
27 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object. 29 * @return {!mediaRouterMojom.MediaSink} A Mojo MediaSink object.
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 /** 416 /**
415 * @param {string} routeId 417 * @param {string} routeId
416 * @param {!Array<!RouteMessage>} mesages 418 * @param {!Array<!RouteMessage>} mesages
417 */ 419 */
418 MediaRouter.prototype.onRouteMessagesReceived = function(routeId, messages) { 420 MediaRouter.prototype.onRouteMessagesReceived = function(routeId, messages) {
419 this.service_.onRouteMessagesReceived( 421 this.service_.onRouteMessagesReceived(
420 routeId, messages.map(messageToMojo_)); 422 routeId, messages.map(messageToMojo_));
421 }; 423 };
422 424
423 /** 425 /**
426 * Creates a MediaRemotingSession that manages content remoting from the given
427 * media source. Only one session can be created for the same source; and an
428 * attempt to create a second before MediaRemotingSession.Terminate() is
429 * called will cause a null handle to be returned.
430 * @param {!string} sourceUrn
431 * @param {!MediaRemotingProvider} provider
432 * @return {!Promise<MediaRemotingSession>} A proxy interface to the remote
433 * MediaRemotingSession. On failure, the proxy is not bound.
434 */
435 MediaRouter.prototype.createRemotingSession =
436 function(sourceUrn, provider) {
437 return this.service_.createRemotingSession(sourceUrn, provider).then(
438 function(result) {
439 return connector.bindHandleToProxy(
440 result.remoting_session,
441 mediaRemoterMojom.MediaRemotingSession);
442 });
443 };
444
445 /**
424 * Object containing callbacks set by the provider manager. 446 * Object containing callbacks set by the provider manager.
425 * 447 *
426 * @constructor 448 * @constructor
427 * @struct 449 * @struct
428 */ 450 */
429 function MediaRouterHandlers() { 451 function MediaRouterHandlers() {
430 /** 452 /**
431 * @type {function(!string, !string, !string, !string, !number)} 453 * @type {function(!string, !string, !string, !string, !number)}
432 */ 454 */
433 this.createRoute = null; 455 this.createRoute = null;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 // TODO(btolsch): Remove this check when we no longer expect old extensions 857 // TODO(btolsch): Remove this check when we no longer expect old extensions
836 // to be missing this API. 858 // to be missing this API.
837 if (!this.handlers_.searchSinks) { 859 if (!this.handlers_.searchSinks) {
838 return Promise.resolve({'sink_id': ''}); 860 return Promise.resolve({'sink_id': ''});
839 } 861 }
840 return Promise.resolve({ 862 return Promise.resolve({
841 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) 863 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria)
842 }); 864 });
843 }; 865 };
844 866
867 /**
868 * Routes calls from the MediaRemotingSession in the browser process to the
869 * provider manager extension.
870 * @param {!object} Delegate that provides the MediaRemotingProvider
871 * implementation, which itself contains state relative to a specific
872 * MediaRemotingSession.
873 * @constructor
874 */
875 function MediaRemotingProvider(delegate) {
876 mediaRemoterMojom.MediaRemotingProvider.stubClass.call(this);
877
878 this.delegate_ = delegate;
879 const requiredMethods = [
880 'startMediaServices',
881 'stopMediaServices',
882 'sendMessageToRemote',
883 'onSessionTerminated',
884 ];
885 requiredMethods.forEach(function(name) {
886 if (!delegate || !(delegate[name] instanceof Function)) {
887 console.error(name + ' method not implemented.');
888 }
889 });
890 };
891 MediaRemotingProvider.prototype = Object.create(
892 mediaRemoterMojom.MediaRemotingProvider.stubClass.prototype);
893
894 /**
895 * Notifies the provider that remote media services have started.
896 */
897 MediaRemotingProvider.prototype.startMediaServices() {
898 this.delegate_.startMediaServices();
899 }
900
901 /**
902 * Notifies the provider that remote media services have stopped.
903 * @param{?string=} errorReason If specified, a human-readable string
904 * indicating remoting was stopped due to an error; otherwise, it is stopping
905 * normally.
906 */
907 MediaRemotingProvider.prototype.stopMediaServices(errorReason) {
908 this.delegate_.stopMediaServices(errorReason);
909 }
910
911 /**
912 * Forwards a message, via the provider, to the remote's media services.
913 * @param{!Object} message An array of byte values (can be any type of object
914 * that supports array-like operations, such as: string, Array, TypedArray).
915 */
916 MediaRemotingProvider.prototype.sendMessageToRemote(message) {
917 this.delegate_.sendMessageToRemote(message);
918 }
919
920 /**
921 * Notifies the provider that the MediaRemotingSession has been terminated.
922 * @param{?string=} errorReason If specified, a human-readable string
923 * indicating that the session was terminated due to an error; otherwise, it
924 * is terminating normally.
925 */
926 MediaRemotingProvider.prototype.onSessionTerminated(errorReason) {
927 this.delegate_.onSessionTerminated(errorReason);
928 }
929
845 mediaRouter = new MediaRouter(connector.bindHandleToProxy( 930 mediaRouter = new MediaRouter(connector.bindHandleToProxy(
846 serviceProvider.connectToService( 931 serviceProvider.connectToService(
847 mediaRouterMojom.MediaRouter.name), 932 mediaRouterMojom.MediaRouter.name),
848 mediaRouterMojom.MediaRouter)); 933 mediaRouterMojom.MediaRouter));
849 934
850 return mediaRouter; 935 return mediaRouter;
851 }); 936 });
852
OLDNEW
« no previous file with comments | « extensions/renderer/resources/extensions_renderer_resources.grd ('k') | media/mojo/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698