summaryrefslogtreecommitdiffstats
path: root/extensions/renderer
diff options
context:
space:
mode:
authorimcheng <imcheng@chromium.org>2016-02-22 22:34:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-23 06:36:12 +0000
commited10e96f38114815495521e730d5cf29aed9f9b6 (patch)
treece039f54e999d652dfda75c03ad6fab1fb302575 /extensions/renderer
parent882a2c3c2f234012ec5cbd2951d4c03f45ccbe7e (diff)
downloadchromium_src-ed10e96f38114815495521e730d5cf29aed9f9b6.zip
chromium_src-ed10e96f38114815495521e730d5cf29aed9f9b6.tar.gz
chromium_src-ed10e96f38114815495521e730d5cf29aed9f9b6.tar.bz2
[MediaRouter] Plumb PresentationConnectionClose from MR to Blink.
Added some follow up plumbing in Blink for close reason, as well as to send the new event via a new method in PresentationConnection. Added plumbing in PresentationDispatcher and PresentationServiceImpl. Added a new class to hold the (state change, close) callbacks in content public API which will be used by PresentationServiceImpl and MR. Changed existing MR API to take the new callbacks object. Added new MediaRouterMojoImpl API to be notified of presentation connection close. Added plumbing in media_router_bindings.js TODO: add tests BUG=579360,574233,574234 Review URL: https://codereview.chromium.org/1701143002 Cr-Commit-Position: refs/heads/master@{#376935}
Diffstat (limited to 'extensions/renderer')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 0ad0ae8..0b0bee0 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -123,6 +123,28 @@ define('media_router_bindings', [
}
/**
+ * Converts presentation connection close reason to Mojo enum value.
+ * @param {!string} reason
+ * @return {!mediaRouterMojom.MediaRouter.PresentationConnectionCloseReason}
+ */
+ function presentationConnectionCloseReasonToMojo_(reason) {
+ var PresentationConnectionCloseReason =
+ mediaRouterMojom.MediaRouter.PresentationConnectionCloseReason;
+ switch (state) {
+ case 'error':
+ return PresentationConnectionCloseReason.CONNECTION_ERROR;
+ case 'closed':
+ return PresentationConnectionCloseReason.CLOSED;
+ case 'went_away':
+ return PresentationConnectionCloseReason.WENT_AWAY;
+ default:
+ console.error('Unknown presentation connection close reason : ' +
+ reason);
+ return PresentationConnectionCloseReason.CONNECTION_ERROR;
+ }
+ }
+
+ /**
* Parses the given route request Error object and converts it to the
* corresponding result code.
* @param {!Error} error
@@ -351,8 +373,8 @@ define('media_router_bindings', [
/**
* Called by the provider manager when the state of a presentation connected
* to a route has changed.
- * @param {!string} routeId
- * @param {!string} state
+ * @param {string} routeId
+ * @param {string} state
*/
MediaRouter.prototype.onPresentationConnectionStateChanged =
function(routeId, state) {
@@ -361,6 +383,19 @@ define('media_router_bindings', [
};
/**
+ * Called by the provider manager when the state of a presentation connected
+ * to a route has closed.
+ * @param {string} routeId
+ * @param {string} reason
+ * @param {string} message
+ */
+ MediaRouter.prototype.onPresentationConnectionClosed =
+ function(routeId, reason, message) {
+ this.service_.onPresentationConnectionClosed(
+ routeId, presentationConnectionCloseReasonToMojo_(state), message);
+ };
+
+ /**
* Object containing callbacks set by the provider manager.
*
* @constructor