summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/resources
diff options
context:
space:
mode:
authorimcheng <imcheng@chromium.org>2015-08-20 23:09:41 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-21 06:10:11 +0000
commitfd05bc86a3fb7e4fc2c3a8a0477cf619e455e809 (patch)
tree56d94b5c0056576c24c1cfb9a2acf53e64feb628 /extensions/renderer/resources
parent47c16608261eb4b64e530c35ec6d5665f64c15da (diff)
downloadchromium_src-fd05bc86a3fb7e4fc2c3a8a0477cf619e455e809.zip
chromium_src-fd05bc86a3fb7e4fc2c3a8a0477cf619e455e809.tar.gz
chromium_src-fd05bc86a3fb7e4fc2c3a8a0477cf619e455e809.tar.bz2
[Media Router] Implement stopListeningForRouteMessages.
NOTE: This continues from https://codereview.chromium.org/1298163003/ since I wanted to upload this patch using my @chromium.org acct. stopListeningForRouteMessages for media_router.mojom serves to resolve the outstanding Mojo callback for a given listenForRouteMessages call. When the call is received, the outstanding callback/promise will be resolved with an empty list. We also change the semantics of return value of listenForRouteMessages to return an additional bool to indicate whether a permanent error occurred. In cases where |error| is true, MRMojoImpl will stop asking for next batch of msgs for that route. Note: this patch should be landed around the same time as the patch that implements stopListeningForRouteMessages in extension. BUG=520204 Review URL: https://codereview.chromium.org/1307723002 Cr-Commit-Position: refs/heads/master@{#344703}
Diffstat (limited to 'extensions/renderer/resources')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 6c711fd..6491d88 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -321,11 +321,17 @@ define('media_router_bindings', [
this.sendRouteBinaryMessage = null;
/**
- * @type {function(string): Promise.<Array.<RouteMessage>>}
+ * @type {function(string):
+ * Promise.<{messages: Array.<RouteMessage>, error: boolean}>}
*/
this.listenForRouteMessages = null;
/**
+ * @type {function(string)}
+ */
+ this.stopListeningForRouteMessages = null;
+
+ /**
* @type {function()}
*/
this.startObservingMediaRoutes = null;
@@ -375,6 +381,7 @@ define('media_router_bindings', [
'sendRouteMessage',
'sendRouteBinaryMessage',
'listenForRouteMessages',
+ 'stopListeningForRouteMessages',
'closeRoute',
'joinRoute',
'createRoute',
@@ -504,19 +511,30 @@ define('media_router_bindings', [
/**
* Listen for next batch of messages from one of the routeIds.
* @param {!string} routeId
- * @return {!Promise.<Array.<RouteMessage>>} Resolved with a list of messages,
- * an empty list if an error occurred.
+ * @return {!Promise.<{messages: Array.<RouteMessage>, error: boolean}>}
+ * Resolved with a list of messages, and a boolean indicating if an error
+ * occurred.
*/
MediaRouteProvider.prototype.listenForRouteMessages = function(routeId) {
return this.handlers_.listenForRouteMessages(routeId)
.then(function(messages) {
- return {'messages': messages.map(messageToMojo_)};
+ return {'messages': messages.map(messageToMojo_), 'error': false};
}, function() {
- return {'messages': []};
+ return {'messages': [], 'error': true};
});
};
/**
+ * If there is an outstanding |listenForRouteMessages| promise for
+ * |routeId|, resolve that promise with an empty array.
+ * @param {!string} routeId
+ */
+ MediaRouteProvider.prototype.stopListeningForRouteMessages = function(
+ routeId) {
+ return this.handlers_.stopListeningForRouteMessages(routeId);
+ };
+
+ /**
* Requests that the provider manager start sending information about active
* media routes to the Media Router.
*/