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