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