Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: mojo/public/js/new_bindings/interface_types.js

Issue 2893493002: Mojo JS bindings: update the new bindings with the associated interface feature. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 (function() {
6 var internal = mojo.internal;
7
8 // Constants ----------------------------------------------------------------
9 var kInterfaceIdNamespaceMask = 0x80000000;
10 var kMasterInterfaceId = 0x00000000;
11 var kInvalidInterfaceId = 0xFFFFFFFF;
12
6 // --------------------------------------------------------------------------- 13 // ---------------------------------------------------------------------------
7 14
8 function InterfacePtrInfo(handle, version) { 15 function InterfacePtrInfo(handle, version) {
9 this.handle = handle; 16 this.handle = handle;
10 this.version = version; 17 this.version = version;
11 } 18 }
12 19
13 InterfacePtrInfo.prototype.isValid = function() { 20 InterfacePtrInfo.prototype.isValid = function() {
14 return this.handle instanceof MojoHandle; 21 return this.handle instanceof MojoHandle;
15 }; 22 };
16 23
17 InterfacePtrInfo.prototype.close = function() { 24 InterfacePtrInfo.prototype.close = function() {
18 if (!this.isValid()) 25 if (!this.isValid())
19 return; 26 return;
20 27
21 this.handle.close(); 28 this.handle.close();
22 this.handle = null; 29 this.handle = null;
23 this.version = 0; 30 this.version = 0;
24 }; 31 };
25 32
33 function AssociatedInterfacePtrInfo(interfaceEndpointHandle, version) {
34 this.interfaceEndpointHandle = interfaceEndpointHandle;
35 this.version = version;
36 }
37
38 AssociatedInterfacePtrInfo.prototype.isValid = function() {
39 return this.interfaceEndpointHandle.isValid();
40 };
41
26 // --------------------------------------------------------------------------- 42 // ---------------------------------------------------------------------------
27 43
28 function InterfaceRequest(handle) { 44 function InterfaceRequest(handle) {
29 this.handle = handle; 45 this.handle = handle;
30 } 46 }
31 47
32 InterfaceRequest.prototype.isValid = function() { 48 InterfaceRequest.prototype.isValid = function() {
33 return this.handle instanceof MojoHandle; 49 return this.handle instanceof MojoHandle;
34 }; 50 };
35 51
36 InterfaceRequest.prototype.close = function() { 52 InterfaceRequest.prototype.close = function() {
37 if (!this.isValid()) 53 if (!this.isValid())
38 return; 54 return;
39 55
40 this.handle.close(); 56 this.handle.close();
41 this.handle = null; 57 this.handle = null;
42 }; 58 };
43 59
60 function AssociatedInterfaceRequest(interfaceEndpointHandle) {
61 this.interfaceEndpointHandle = interfaceEndpointHandle;
62 }
63
64 AssociatedInterfaceRequest.prototype.isValid = function() {
65 return this.interfaceEndpointHandle.isValid();
66 };
67
68 AssociatedInterfaceRequest.prototype.resetWithReason = function(reason) {
69 this.interfaceEndpointHandle.reset(reason);
70 };
71
72 function isMasterInterfaceId(interfaceId) {
73 return interfaceId === kMasterInterfaceId;
74 }
75
76 function isValidInterfaceId(interfaceId) {
77 return interfaceId !== kInvalidInterfaceId;
78 }
79
44 mojo.InterfacePtrInfo = InterfacePtrInfo; 80 mojo.InterfacePtrInfo = InterfacePtrInfo;
45 mojo.InterfaceRequest = InterfaceRequest; 81 mojo.InterfaceRequest = InterfaceRequest;
82 mojo.AssociatedInterfacePtrInfo = AssociatedInterfacePtrInfo;
83 mojo.AssociatedInterfaceRequest = AssociatedInterfaceRequest;
84 internal.isMasterInterfaceId = isMasterInterfaceId;
85 internal.isValidInterfaceId = isValidInterfaceId;
86 internal.kInvalidInterfaceId = kInvalidInterfaceId;
87 internal.kMasterInterfaceId = kMasterInterfaceId;
88 internal.kInterfaceIdNamespaceMask = kInterfaceIdNamespaceMask;
46 })(); 89 })();
OLDNEW
« no previous file with comments | « mojo/public/js/new_bindings/connector.js ('k') | mojo/public/js/new_bindings/lib/control_message_handler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698