summaryrefslogtreecommitdiff
path: root/mojo/public/js/new_bindings/interface_types.js
blob: 01ea2d1dd466a76f2f5ccb1259efe0eac00a1677 (plain)
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
// 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.

define("mojo/public/js/interface_types", [
  "mojo/public/js/core",
], function(core) {

  // ---------------------------------------------------------------------------

  function InterfacePtrInfo(handle, version) {
    this.handle = handle;
    this.version = version;
  }

  InterfacePtrInfo.prototype.isValid = function() {
    return core.isHandle(this.handle);
  };

  InterfacePtrInfo.prototype.close = function() {
    if (!this.isValid())
      return;

    core.close(this.handle);
    this.handle = null;
    this.version = 0;
  };

  // ---------------------------------------------------------------------------

  function InterfaceRequest(handle) {
    this.handle = handle;
  }

  InterfaceRequest.prototype.isValid = function() {
    return core.isHandle(this.handle);
  };

  InterfaceRequest.prototype.close = function() {
    if (!this.isValid())
      return;

    core.close(this.handle);
    this.handle = null;
  };

  var exports = {};
  exports.InterfacePtrInfo = InterfacePtrInfo;
  exports.InterfaceRequest = InterfaceRequest;

  return exports;
});