1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
mojo / public / js / interface_types.js [blame]
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
var internal = mojo.internal;
// Constants ----------------------------------------------------------------
var kInterfaceIdNamespaceMask = 0x80000000;
var kPrimaryInterfaceId = 0x00000000;
var kInvalidInterfaceId = 0xFFFFFFFF;
// ---------------------------------------------------------------------------
function InterfacePtrInfo(handle, version) {
this.handle = handle;
this.version = version;
}
InterfacePtrInfo.prototype.isValid = function() {
return this.handle instanceof MojoHandle;
};
InterfacePtrInfo.prototype.close = function() {
if (!this.isValid())
return;
this.handle.close();
this.handle = null;
this.version = 0;
};
function AssociatedInterfacePtrInfo(interfaceEndpointHandle, version) {
this.interfaceEndpointHandle = interfaceEndpointHandle;
this.version = version;
}
AssociatedInterfacePtrInfo.prototype.isValid = function() {
return this.interfaceEndpointHandle.isValid();
};
// ---------------------------------------------------------------------------
function InterfaceRequest(handle) {
this.handle = handle;
}
InterfaceRequest.prototype.isValid = function() {
return this.handle instanceof MojoHandle;
};
InterfaceRequest.prototype.close = function() {
if (!this.isValid())
return;
this.handle.close();
this.handle = null;
};
function AssociatedInterfaceRequest(interfaceEndpointHandle) {
this.interfaceEndpointHandle = interfaceEndpointHandle;
}
AssociatedInterfaceRequest.prototype.isValid = function() {
return this.interfaceEndpointHandle.isValid();
};
AssociatedInterfaceRequest.prototype.resetWithReason = function(reason) {
this.interfaceEndpointHandle.reset(reason);
};
function isPrimaryInterfaceId(interfaceId) {
return interfaceId === kPrimaryInterfaceId;
}
function isValidInterfaceId(interfaceId) {
return interfaceId !== kInvalidInterfaceId;
}
function hasInterfaceIdNamespaceBitSet(interfaceId) {
if (interfaceId >= 2 * kInterfaceIdNamespaceMask) {
throw new Error("Interface ID should be a 32-bit unsigned integer.");
}
return interfaceId >= kInterfaceIdNamespaceMask;
}
mojo.InterfacePtrInfo = InterfacePtrInfo;
mojo.InterfaceRequest = InterfaceRequest;
mojo.AssociatedInterfacePtrInfo = AssociatedInterfacePtrInfo;
mojo.AssociatedInterfaceRequest = AssociatedInterfaceRequest;
internal.isPrimaryInterfaceId = isPrimaryInterfaceId;
internal.isValidInterfaceId = isValidInterfaceId;
internal.hasInterfaceIdNamespaceBitSet = hasInterfaceIdNamespaceBitSet;
internal.kInvalidInterfaceId = kInvalidInterfaceId;
internal.kPrimaryInterfaceId = kPrimaryInterfaceId;
internal.kInterfaceIdNamespaceMask = kInterfaceIdNamespaceMask;
})();