| 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 "mojo/public/js/core", |
| 7 ], function(core) { | 7 ], function(core) { |
| 8 | 8 |
| 9 // Constants ---------------------------------------------------------------- | |
| 10 var kInterfaceIdNamespaceMask = 0x80000000; | |
| 11 var kMasterInterfaceId = 0x00000000; | |
| 12 var kInvalidInterfaceId = 0xFFFFFFFF; | |
| 13 | |
| 14 // --------------------------------------------------------------------------- | 9 // --------------------------------------------------------------------------- |
| 15 | 10 |
| 16 function InterfacePtrInfo(handle, version) { | 11 function InterfacePtrInfo(handle, version) { |
| 17 this.handle = handle; | 12 this.handle = handle; |
| 18 this.version = version; | 13 this.version = version; |
| 19 } | 14 } |
| 20 | 15 |
| 21 InterfacePtrInfo.prototype.isValid = function() { | 16 InterfacePtrInfo.prototype.isValid = function() { |
| 22 return core.isHandle(this.handle); | 17 return core.isHandle(this.handle); |
| 23 }; | 18 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 }; | 37 }; |
| 43 | 38 |
| 44 InterfaceRequest.prototype.close = function() { | 39 InterfaceRequest.prototype.close = function() { |
| 45 if (!this.isValid()) | 40 if (!this.isValid()) |
| 46 return; | 41 return; |
| 47 | 42 |
| 48 core.close(this.handle); | 43 core.close(this.handle); |
| 49 this.handle = null; | 44 this.handle = null; |
| 50 }; | 45 }; |
| 51 | 46 |
| 52 function isMasterInterfaceId(interfaceId) { | |
| 53 return interfaceId === kMasterInterfaceId; | |
| 54 } | |
| 55 | |
| 56 function isValidInterfaceId(interfaceId) { | |
| 57 return interfaceId !== kInvalidInterfaceId; | |
| 58 } | |
| 59 | |
| 60 var exports = {}; | 47 var exports = {}; |
| 61 exports.InterfacePtrInfo = InterfacePtrInfo; | 48 exports.InterfacePtrInfo = InterfacePtrInfo; |
| 62 exports.InterfaceRequest = InterfaceRequest; | 49 exports.InterfaceRequest = InterfaceRequest; |
| 63 exports.isMasterInterfaceId = isMasterInterfaceId; | |
| 64 exports.isValidInterfaceId = isValidInterfaceId; | |
| 65 exports.kInvalidInterfaceId = kInvalidInterfaceId; | |
| 66 exports.kMasterInterfaceId = kMasterInterfaceId; | |
| 67 exports.kInterfaceIdNamespaceMask = kInterfaceIdNamespaceMask; | |
| 68 | 50 |
| 69 return exports; | 51 return exports; |
| 70 }); | 52 }); |
| OLD | NEW |