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

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

Issue 2324133003: [Media Router] Use TimeDelta in mojo interfaces (Closed)
Patch Set: Created 4 years, 3 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_interfaces', 10 'content/public/renderer/frame_interfaces',
11 'chrome/browser/media/router/mojo/media_router.mojom', 11 'chrome/browser/media/router/mojo/media_router.mojom',
12 'extensions/common/mojo/keep_alive.mojom', 12 'extensions/common/mojo/keep_alive.mojom',
13 'mojo/common/common_custom_types.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 frameInterfaces, 18 frameInterfaces,
18 mediaRouterMojom, 19 mediaRouterMojom,
19 keepAliveMojom, 20 keepAliveMojom,
21 commonCustomTypesMojom,
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.
28 */ 30 */
29 function sinkToMojo_(sink) { 31 function sinkToMojo_(sink) {
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 /** 594 /**
593 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the 595 * Requests that |sinkId| render the media referenced by |sourceUrn|. If the
594 * request is from the Presentation API, then origin and tabId will 596 * request is from the Presentation API, then origin and tabId will
595 * be populated. 597 * be populated.
596 * @param {!string} sourceUrn Media source to render. 598 * @param {!string} sourceUrn Media source to render.
597 * @param {!string} sinkId Media sink ID. 599 * @param {!string} sinkId Media sink ID.
598 * @param {!string} presentationId Presentation ID from the site 600 * @param {!string} presentationId Presentation ID from the site
599 * requesting presentation. TODO(mfoltz): Remove. 601 * requesting presentation. TODO(mfoltz): Remove.
600 * @param {!string} origin Origin of site requesting presentation. 602 * @param {!string} origin Origin of site requesting presentation.
601 * @param {!number} tabId ID of tab requesting presentation. 603 * @param {!number} tabId ID of tab requesting presentation.
602 * @param {!number} timeoutMillis If positive, the timeout duration for the 604 * @param {!TimeDelta} timeout If positive, the timeout duration for the
603 * request, measured in seconds. Otherwise, the default duration will be 605 * request, measured in microseconds. Otherwise, the default duration will
miu 2016/09/10 00:40:17 nit: Please remove "measured in microseconds" sinc
btolsch 2016/09/10 00:51:39 Done.
604 * used. 606 * be used.
605 * @param {!boolean} incognito If true, the route is being requested by 607 * @param {!boolean} incognito If true, the route is being requested by
606 * an incognito profile. 608 * an incognito profile.
607 * @return {!Promise.<!Object>} A Promise resolving to an object describing 609 * @return {!Promise.<!Object>} A Promise resolving to an object describing
608 * the newly created media route, or rejecting with an error message on 610 * the newly created media route, or rejecting with an error message on
609 * failure. 611 * failure.
610 */ 612 */
611 MediaRouteProvider.prototype.createRoute = 613 MediaRouteProvider.prototype.createRoute =
612 function(sourceUrn, sinkId, presentationId, origin, tabId, 614 function(sourceUrn, sinkId, presentationId, origin, tabId,
613 timeoutMillis, incognito) { 615 timeout, incognito) {
614 return this.handlers_.createRoute( 616 return this.handlers_.createRoute(
615 sourceUrn, sinkId, presentationId, origin, tabId, timeoutMillis, 617 sourceUrn, sinkId, presentationId, origin, tabId,
616 incognito) 618 Math.floor(timeout.microseconds / 1000), incognito)
617 .then(function(route) { 619 .then(function(route) {
618 return toSuccessRouteResponse_(route); 620 return toSuccessRouteResponse_(route);
619 }, 621 },
620 function(err) { 622 function(err) {
621 return toErrorRouteResponse_(err); 623 return toErrorRouteResponse_(err);
622 }); 624 });
623 }; 625 };
624 626
625 /** 627 /**
626 * Handles a request via the Presentation API to join an existing route given 628 * Handles a request via the Presentation API to join an existing route given
627 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for 629 * by |sourceUrn| and |presentationId|. |origin| and |tabId| are used for
628 * validating same-origin/tab scope. 630 * validating same-origin/tab scope.
629 * @param {!string} sourceUrn Media source to render. 631 * @param {!string} sourceUrn Media source to render.
630 * @param {!string} presentationId Presentation ID to join. 632 * @param {!string} presentationId Presentation ID to join.
631 * @param {!string} origin Origin of site requesting join. 633 * @param {!string} origin Origin of site requesting join.
632 * @param {!number} tabId ID of tab requesting join. 634 * @param {!number} tabId ID of tab requesting join.
633 * @param {!number} timeoutMillis If positive, the timeout duration for the 635 * @param {!TimeDelta} timeout If positive, the timeout duration for the
634 * request, measured in seconds. Otherwise, the default duration will be 636 * request, measured in microseconds. Otherwise, the default duration will
635 * used. 637 * be used.
636 * @param {!boolean} incognito If true, the route is being requested by 638 * @param {!boolean} incognito If true, the route is being requested by
637 * an incognito profile. 639 * an incognito profile.
638 * @return {!Promise.<!Object>} A Promise resolving to an object describing 640 * @return {!Promise.<!Object>} A Promise resolving to an object describing
639 * the newly created media route, or rejecting with an error message on 641 * the newly created media route, or rejecting with an error message on
640 * failure. 642 * failure.
641 */ 643 */
642 MediaRouteProvider.prototype.joinRoute = 644 MediaRouteProvider.prototype.joinRoute =
643 function(sourceUrn, presentationId, origin, tabId, timeoutMillis, 645 function(sourceUrn, presentationId, origin, tabId, timeoutMillis,
644 incognito) { 646 incognito) {
645 return this.handlers_.joinRoute( 647 return this.handlers_.joinRoute(
646 sourceUrn, presentationId, origin, tabId, timeoutMillis, incognito) 648 sourceUrn, presentationId, origin, tabId,
649 Math.floor(timeout.microseconds / 1000), incognito)
647 .then(function(route) { 650 .then(function(route) {
648 return toSuccessRouteResponse_(route); 651 return toSuccessRouteResponse_(route);
649 }, 652 },
650 function(err) { 653 function(err) {
651 return toErrorRouteResponse_(err); 654 return toErrorRouteResponse_(err);
652 }); 655 });
653 }; 656 };
654 657
655 /** 658 /**
656 * Handles a request via the Presentation API to join an existing route given 659 * Handles a request via the Presentation API to join an existing route given
657 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for 660 * by |sourceUrn| and |routeId|. |origin| and |tabId| are used for
658 * validating same-origin/tab scope. 661 * validating same-origin/tab scope.
659 * @param {!string} sourceUrn Media source to render. 662 * @param {!string} sourceUrn Media source to render.
660 * @param {!string} routeId Route ID to join. 663 * @param {!string} routeId Route ID to join.
661 * @param {!string} presentationId Presentation ID to join. 664 * @param {!string} presentationId Presentation ID to join.
662 * @param {!string} origin Origin of site requesting join. 665 * @param {!string} origin Origin of site requesting join.
663 * @param {!number} tabId ID of tab requesting join. 666 * @param {!number} tabId ID of tab requesting join.
664 * @param {!number} timeoutMillis If positive, the timeout duration for the 667 * @param {!TimeDelta} timeout If positive, the timeout duration for the
665 * request, measured in seconds. Otherwise, the default duration will be 668 * request, measured in microseconds. Otherwise, the default duration will
666 * used. 669 * be used.
667 * @param {!boolean} incognito If true, the route is being requested by 670 * @param {!boolean} incognito If true, the route is being requested by
668 * an incognito profile. 671 * an incognito profile.
669 * @return {!Promise.<!Object>} A Promise resolving to an object describing 672 * @return {!Promise.<!Object>} A Promise resolving to an object describing
670 * the newly created media route, or rejecting with an error message on 673 * the newly created media route, or rejecting with an error message on
671 * failure. 674 * failure.
672 */ 675 */
673 MediaRouteProvider.prototype.connectRouteByRouteId = 676 MediaRouteProvider.prototype.connectRouteByRouteId =
674 function(sourceUrn, routeId, presentationId, origin, tabId, 677 function(sourceUrn, routeId, presentationId, origin, tabId,
675 timeoutMillis, incognito) { 678 timeout, incognito) {
676 return this.handlers_.connectRouteByRouteId( 679 return this.handlers_.connectRouteByRouteId(
677 sourceUrn, routeId, presentationId, origin, tabId, timeoutMillis, 680 sourceUrn, routeId, presentationId, origin, tabId,
678 incognito) 681 Math.floor(timeout.microseconds / 1000), incognito)
679 .then(function(route) { 682 .then(function(route) {
680 return toSuccessRouteResponse_(route); 683 return toSuccessRouteResponse_(route);
681 }, 684 },
682 function(err) { 685 function(err) {
683 return toErrorRouteResponse_(err); 686 return toErrorRouteResponse_(err);
684 }); 687 });
685 }; 688 };
686 689
687 /** 690 /**
688 * Terminates the route specified by |routeId|. 691 * Terminates the route specified by |routeId|.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 }); 858 });
856 }; 859 };
857 860
858 mediaRouter = new MediaRouter(connector.bindHandleToProxy( 861 mediaRouter = new MediaRouter(connector.bindHandleToProxy(
859 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), 862 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name),
860 mediaRouterMojom.MediaRouter)); 863 mediaRouterMojom.MediaRouter));
861 864
862 return mediaRouter; 865 return mediaRouter;
863 }); 866 });
864 867
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698