| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/interface_types", [ | 5 define("mojo/public/js/interface_types", [ |
| 6 "mojo/public/js/core", | 6 ], function() { |
| 7 ], function(core) { | |
| 8 | 7 |
| 9 // --------------------------------------------------------------------------- | 8 // --------------------------------------------------------------------------- |
| 10 | 9 |
| 11 function InterfacePtrInfo(handle, version) { | 10 function InterfacePtrInfo(handle, version) { |
| 12 this.handle = handle; | 11 this.handle = handle; |
| 13 this.version = version; | 12 this.version = version; |
| 14 } | 13 } |
| 15 | 14 |
| 16 InterfacePtrInfo.prototype.isValid = function() { | 15 InterfacePtrInfo.prototype.isValid = function() { |
| 17 return core.isHandle(this.handle); | 16 return this.handle instanceof MojoHandle; |
| 18 }; | 17 }; |
| 19 | 18 |
| 20 InterfacePtrInfo.prototype.close = function() { | 19 InterfacePtrInfo.prototype.close = function() { |
| 21 if (!this.isValid()) | 20 if (!this.isValid()) |
| 22 return; | 21 return; |
| 23 | 22 |
| 24 core.close(this.handle); | 23 this.handle.close(); |
| 25 this.handle = null; | 24 this.handle = null; |
| 26 this.version = 0; | 25 this.version = 0; |
| 27 }; | 26 }; |
| 28 | 27 |
| 29 // --------------------------------------------------------------------------- | 28 // --------------------------------------------------------------------------- |
| 30 | 29 |
| 31 function InterfaceRequest(handle) { | 30 function InterfaceRequest(handle) { |
| 32 this.handle = handle; | 31 this.handle = handle; |
| 33 } | 32 } |
| 34 | 33 |
| 35 InterfaceRequest.prototype.isValid = function() { | 34 InterfaceRequest.prototype.isValid = function() { |
| 36 return core.isHandle(this.handle); | 35 return this.handle instanceof MojoHandle; |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 InterfaceRequest.prototype.close = function() { | 38 InterfaceRequest.prototype.close = function() { |
| 40 if (!this.isValid()) | 39 if (!this.isValid()) |
| 41 return; | 40 return; |
| 42 | 41 |
| 43 core.close(this.handle); | 42 this.handle.close(); |
| 44 this.handle = null; | 43 this.handle = null; |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 var exports = {}; | 46 var exports = {}; |
| 48 exports.InterfacePtrInfo = InterfacePtrInfo; | 47 exports.InterfacePtrInfo = InterfacePtrInfo; |
| 49 exports.InterfaceRequest = InterfaceRequest; | 48 exports.InterfaceRequest = InterfaceRequest; |
| 50 | 49 |
| 51 return exports; | 50 return exports; |
| 52 }); | 51 }); |
| OLD | NEW |