summaryrefslogtreecommitdiff
path: root/mojo/public/js/new_bindings/interface_types.js
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/public/js/new_bindings/interface_types.js')
-rw-r--r--mojo/public/js/new_bindings/interface_types.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/mojo/public/js/new_bindings/interface_types.js b/mojo/public/js/new_bindings/interface_types.js
new file mode 100644
index 0000000000..c52f6c7e55
--- /dev/null
+++ b/mojo/public/js/new_bindings/interface_types.js
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+ // ---------------------------------------------------------------------------
+
+ 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 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;
+ };
+
+ mojo.InterfacePtrInfo = InterfacePtrInfo;
+ mojo.InterfaceRequest = InterfaceRequest;
+})();