summaryrefslogtreecommitdiffstats
path: root/extensions/renderer
diff options
context:
space:
mode:
authorimcheng <imcheng@chromium.org>2015-11-10 10:26:30 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-10 18:27:55 +0000
commitd62bdca33858df9e8b20831a423659fc53a442b8 (patch)
tree1c903bc8c793c72b61d5f47b81f480d8f0e797d4 /extensions/renderer
parentdd1b4ad61b745e8d75195cd0b4938086d3b6062d (diff)
downloadchromium_src-d62bdca33858df9e8b20831a423659fc53a442b8.zip
chromium_src-d62bdca33858df9e8b20831a423659fc53a442b8.tar.gz
chromium_src-d62bdca33858df9e8b20831a423659fc53a442b8.tar.bz2
[Media Router] Add PresentationConnectionStateObserver and related APIs.
Introduce PresentationConnectionStateObserver class to listen for connection state updates from MRPM. Added related MR/MRPM APIs. This is implemented as outlined in the proposal for reworking connection state change listening. Depends on crrev.com/1410143006 BUG=529893 Review URL: https://codereview.chromium.org/1414393009 Cr-Commit-Position: refs/heads/master@{#358855}
Diffstat (limited to 'extensions/renderer')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js37
1 files changed, 36 insertions, 1 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index c877fd4..13bf88b 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -98,6 +98,28 @@ define('media_router_bindings', [
}
/**
+ * Converts presentation connection state to Mojo enum value.
+ * @param {!string} state
+ * @return {!mediaRouterMojom.MediaRouter.PresentationConnectionState}
+ */
+ function presentationConnectionStateToMojo_(state) {
+ switch (state) {
+ case 'connected':
+ return
+ mediaRouterMojom.MediaRouter.PresentationConnectionState.CONNECTED;
+ case 'closed':
+ return mediaRouterMojom.MediaRouter.PresentationConnectionState.CLOSED;
+ case 'terminated':
+ return
+ mediaRouterMojom.MediaRouter.PresentationConnectionState.TERMINATED;
+ default:
+ console.error('Unknown presentation connection state: ' + state);
+ return
+ mediaRouterMojom.MediaRouter.PresentationConnectionState.TERMINATED;
+ }
+ }
+
+ /**
* Creates a new MediaRouter.
* Converts a route struct to its Mojo form.
* @param {!MediaRouterService} service
@@ -265,13 +287,26 @@ define('media_router_bindings', [
/**
* Called by the provider manager when sink availability has been updated.
- * @param {!MediaRouter.SinkAvailability} The new sink availability.
+ * @param {!mediaRouterMojom.MediaRouter.SinkAvailability} availability
+ * The new sink availability.
*/
MediaRouter.prototype.onSinkAvailabilityUpdated = function(availability) {
this.service_.onSinkAvailabilityUpdated(availability);
};
/**
+ * Called by the provider manager when the state of a presentation connected
+ * to a route has changed.
+ * @param {!string} routeId
+ * @param {!string} state
+ */
+ MediaRouter.prototype.onPresentationConnectionStateChanged =
+ function(routeId, state) {
+ this.service_.onPresentationConnectionStateChanged(
+ routeId, presentationConnectionStateToMojo_(state));
+ };
+
+ /**
* Object containing callbacks set by the provider manager.
*
* @constructor