| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 define("mojo/public/js/bindings", [ | 5 define("mojo/public/js/bindings", [ |
| 6 "mojo/public/js/router", | 6 "mojo/public/js/router", |
| 7 "mojo/public/js/core", | 7 "mojo/public/js/core", |
| 8 ], function(router, core) { | 8 ], function(router, core) { |
| 9 | 9 |
| 10 var Router = router.Router; | 10 var Router = router.Router; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 // TODO(hansmuller): remove then after 'Client=' has been removed from Mojom. | 26 // TODO(hansmuller): remove then after 'Client=' has been removed from Mojom. |
| 27 ProxyProperties.prototype.setLocalDelegate = function(impl) { | 27 ProxyProperties.prototype.setLocalDelegate = function(impl) { |
| 28 if (this.local) | 28 if (this.local) |
| 29 StubBindings(this.local).delegate = impl; | 29 StubBindings(this.local).delegate = impl; |
| 30 else | 30 else |
| 31 throw new Error("no stub object"); | 31 throw new Error("no stub object"); |
| 32 } | 32 } |
| 33 | 33 |
| 34 function connectionHandle(connection) { | |
| 35 return connection && | |
| 36 connection.router && | |
| 37 connection.router.connector_ && | |
| 38 connection.router.connector_.handle_; | |
| 39 } | |
| 40 | |
| 41 ProxyProperties.prototype.close = function() { | 34 ProxyProperties.prototype.close = function() { |
| 42 var handle = connectionHandle(this.connection); | 35 this.connection.close(); |
| 43 if (handle) | |
| 44 core.close(handle); | |
| 45 } | 36 } |
| 46 | 37 |
| 47 // Public stub class properties that are managed at runtime by the JS | 38 // Public stub class properties that are managed at runtime by the JS |
| 48 // bindings. See StubBindings below. | 39 // bindings. See StubBindings below. |
| 49 function StubProperties(delegate) { | 40 function StubProperties(delegate) { |
| 50 this.delegate = delegate; | 41 this.delegate = delegate; |
| 51 } | 42 } |
| 52 | 43 |
| 53 StubProperties.prototype.close = function() { | 44 StubProperties.prototype.close = function() { |
| 54 var handle = connectionHandle(this.connection); | 45 this.connection.close(); |
| 55 if (handle) | |
| 56 core.close(handle); | |
| 57 } | 46 } |
| 58 | 47 |
| 59 // The base class for generated proxy classes. | 48 // The base class for generated proxy classes. |
| 60 function ProxyBase(receiver) { | 49 function ProxyBase(receiver) { |
| 61 this[kProxyProperties] = new ProxyProperties(receiver); | 50 this[kProxyProperties] = new ProxyProperties(receiver); |
| 62 | 51 |
| 63 // TODO(hansmuller): Temporary, for Chrome backwards compatibility. | 52 // TODO(hansmuller): Temporary, for Chrome backwards compatibility. |
| 64 if (receiver instanceof Router) | 53 if (receiver instanceof Router) |
| 65 this.receiver_ = receiver; | 54 this.receiver_ = receiver; |
| 66 } | 55 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 107 } |
| 119 | 108 |
| 120 var exports = {}; | 109 var exports = {}; |
| 121 exports.EmptyProxy = ProxyBase; | 110 exports.EmptyProxy = ProxyBase; |
| 122 exports.EmptyStub = StubBase; | 111 exports.EmptyStub = StubBase; |
| 123 exports.ProxyBase = ProxyBase; | 112 exports.ProxyBase = ProxyBase; |
| 124 exports.ProxyBindings = ProxyBindings; | 113 exports.ProxyBindings = ProxyBindings; |
| 125 exports.StubBase = StubBase; | 114 exports.StubBase = StubBase; |
| 126 exports.StubBindings = StubBindings; | 115 exports.StubBindings = StubBindings; |
| 127 return exports; | 116 return exports; |
| 128 }); | 117 }); |
| OLD | NEW |