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