| OLD | NEW |
| 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', |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 this.service_ = service; | 199 this.service_ = service; |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * The provider manager service delegate. Its methods are called by the | 202 * The provider manager service delegate. Its methods are called by the |
| 203 * browser-resident Mojo service. | 203 * browser-resident Mojo service. |
| 204 * @type {!MediaRouter} | 204 * @type {!MediaRouter} |
| 205 */ | 205 */ |
| 206 this.mrpm_ = new MediaRouteProvider(this); | 206 this.mrpm_ = new MediaRouteProvider(this); |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * The message pipe that connects the Media Router to mrpm_ across | |
| 210 * browser/renderer IPC boundaries. Object must remain in scope for the | |
| 211 * lifetime of the connection to prevent the connection from closing | |
| 212 * automatically. | |
| 213 * @type {!mojo.MessagePipe} | |
| 214 */ | |
| 215 this.pipe_ = core.createMessagePipe(); | |
| 216 | |
| 217 /** | |
| 218 * Handle to a KeepAlive service object, which prevents the extension from | 209 * Handle to a KeepAlive service object, which prevents the extension from |
| 219 * being suspended as long as it remains in scope. | 210 * being suspended as long as it remains in scope. |
| 220 * @type {boolean} | 211 * @type {boolean} |
| 221 */ | 212 */ |
| 222 this.keepAlive_ = null; | 213 this.keepAlive_ = null; |
| 223 | 214 |
| 224 /** | 215 /** |
| 225 * The stub used to bind the service delegate to the Mojo interface. | 216 * The bindings to bind the service delegate to the Mojo interface. |
| 226 * Object must remain in scope for the lifetime of the connection to | 217 * Object must remain in scope for the lifetime of the connection to |
| 227 * prevent the connection from closing automatically. | 218 * prevent the connection from closing automatically. |
| 228 * @type {!mojom.MediaRouter} | 219 * @type {!bindings.Binding} |
| 229 */ | 220 */ |
| 230 this.mediaRouteProviderStub_ = connector.bindHandleToStub( | 221 this.mediaRouteProviderBinding_ = new bindings.Binding( |
| 231 this.pipe_.handle0, mediaRouterMojom.MediaRouteProvider); | 222 mediaRouterMojom.MediaRouteProvider, this.mrpm_); |
| 232 | |
| 233 // Link mediaRouteProviderStub_ to the provider manager delegate. | |
| 234 bindings.StubBindings(this.mediaRouteProviderStub_).delegate = this.mrpm_; | |
| 235 } | 223 } |
| 236 | 224 |
| 237 /** | 225 /** |
| 238 * Registers the Media Router Provider Manager with the Media Router. | 226 * Registers the Media Router Provider Manager with the Media Router. |
| 239 * @return {!Promise<string>} Instance ID for the Media Router. | 227 * @return {!Promise<string>} Instance ID for the Media Router. |
| 240 */ | 228 */ |
| 241 MediaRouter.prototype.start = function() { | 229 MediaRouter.prototype.start = function() { |
| 242 return this.service_.registerMediaRouteProvider(this.pipe_.handle1).then( | 230 return this.service_.registerMediaRouteProvider( |
| 243 function(result) { | 231 this.mediaRouteProviderBinding_.createInterfacePtrAndBind()).then( |
| 244 return result.instance_id; | 232 function(result) { |
| 245 }.bind(this)); | 233 return result.instance_id; |
| 234 }.bind(this)); |
| 246 } | 235 } |
| 247 | 236 |
| 248 /** | 237 /** |
| 249 * Sets the service delegate methods. | 238 * Sets the service delegate methods. |
| 250 * @param {Object} handlers | 239 * @param {Object} handlers |
| 251 */ | 240 */ |
| 252 MediaRouter.prototype.setHandlers = function(handlers) { | 241 MediaRouter.prototype.setHandlers = function(handlers) { |
| 253 this.mrpm_.setHandlers(handlers); | 242 this.mrpm_.setHandlers(handlers); |
| 254 } | 243 } |
| 255 | 244 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) | 812 'sink_id': this.handlers_.searchSinks(sinkId, sourceUrn, searchCriteria) |
| 824 }); | 813 }); |
| 825 }; | 814 }; |
| 826 | 815 |
| 827 mediaRouter = new MediaRouter(connector.bindHandleToProxy( | 816 mediaRouter = new MediaRouter(connector.bindHandleToProxy( |
| 828 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), | 817 frameInterfaces.getInterface(mediaRouterMojom.MediaRouter.name), |
| 829 mediaRouterMojom.MediaRouter)); | 818 mediaRouterMojom.MediaRouter)); |
| 830 | 819 |
| 831 return mediaRouter; | 820 return mediaRouter; |
| 832 }); | 821 }); |
| OLD | NEW |