summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorimcheng <imcheng@google.com>2015-08-06 18:00:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-07 01:01:39 +0000
commita0b6dc9205a195a4fa8c52a71fa1cb2ae8abb591 (patch)
treed14fc535a1efb5d7667b496920e6a82926f42497 /extensions
parentbb1fa29f61337a14332e6a038b6b09f23d8098b5 (diff)
downloadchromium_src-a0b6dc9205a195a4fa8c52a71fa1cb2ae8abb591.zip
chromium_src-a0b6dc9205a195a4fa8c52a71fa1cb2ae8abb591.tar.gz
chromium_src-a0b6dc9205a195a4fa8c52a71fa1cb2ae8abb591.tar.bz2
[Presentation API] Change ListenForSessionMessages API to observers.
ListenForSessionMessages is now observer style and listens for a single presentation as opposed to all sessions in that frame. This change also separate presentation url / id from the various SessionMessage structs from presentation mojom / content. Now SendSessionMessage / ListenForSessionMessages must pass in an explicit PresentationSessionInfo. Doing this allows us to avoid parsing presenation url/id from route id for presentation session - MediaRoute association, because previously we would have to fill out the url/id field of content::PresentationSessionMessage struct and there was no good way to do it without parsing. Now we simply bind the PresentationSessionInfo to the callback that receives the messages. Removing the pres url/id from the message struct also avoids duplication when sending a batch of messages for the same session. Added PresentationSessionMessagesObserver class and MediaRouter API to implement the observer style API. MediaRouterMojoImpl contains logic to adapt the observer stlye API to the getNext style API for listening for route messages from the Media Route Provider. Another change that were needed to completely remove the route id parsing logic is to invoke MediaRouteResponseCallbacks with the resulting presentation id generated by MediaRouter. This is needed due to browser-initiated presentations where the presentation id is not known in advance. BUG=510297,510267 Review URL: https://codereview.chromium.org/1259073004 Cr-Commit-Position: refs/heads/master@{#342249}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 0c1dca2..95fdcb1 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -63,13 +63,11 @@ define('media_router_bindings', [
function messageToMojo_(message) {
if ("string" == typeof message.message) {
return new mediaRouterMojom.RouteMessage({
- 'route_id': message.routeId,
'type': mediaRouterMojom.RouteMessage.Type.TEXT,
'message': message.message,
});
} else {
return new mediaRouterMojom.RouteMessage({
- 'route_id': message.routeId,
'type': mediaRouterMojom.RouteMessage.Type.BINARY,
'data': message.message,
});
@@ -322,7 +320,7 @@ define('media_router_bindings', [
this.sendRouteBinaryMessage = null;
/**
- * @type {function(Array.<string>): Promise.<Array.<RouteMessage>>}
+ * @type {function(string): Promise.<Array.<RouteMessage>>}
*/
this.listenForRouteMessages = null;
@@ -504,12 +502,12 @@ define('media_router_bindings', [
/**
* Listen for next batch of messages from one of the routeIds.
- * @param {!Array.<string>} routeIds
+ * @param {!string} routeId
* @return {!Promise.<Array.<RouteMessage>>} Resolved with a list of messages,
* an empty list if an error occurred.
*/
- MediaRouteProvider.prototype.listenForRouteMessages = function(routeIds) {
- return this.handlers_.listenForRouteMessages(routeIds)
+ MediaRouteProvider.prototype.listenForRouteMessages = function(routeId) {
+ return this.handlers_.listenForRouteMessages([routeId])
.then(function(messages) {
return {'messages': messages.map(messageToMojo_)};
}, function() {