mojo.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. * @fileoverview Closure definitions of Mojo core IDL and bindings objects.
  3. */
  4. const Mojo = {};
  5. /**
  6. * @param {string} name
  7. * @param {MojoHandle} handle
  8. * @param {string=} scope
  9. */
  10. Mojo.bindInterface = function(name, handle, scope) {};
  11. const MojoHandle = class {};
  12. const mojo = {};
  13. // Core Mojo.
  14. mojo.Binding = class {
  15. /**
  16. * @param {!mojo.Interface} interfaceType
  17. * @param {!Object} impl
  18. * @param {mojo.InterfaceRequest=} request
  19. */
  20. constructor(interfaceType, impl, request) {};
  21. /**
  22. * Closes the message pipe. The bound object will no longer receive messages.
  23. */
  24. close() {}
  25. /**
  26. * Binds to the given request.
  27. * @param {!mojo.InterfaceRequest} request
  28. */
  29. bind(request) {}
  30. /** @param {function()} callback */
  31. setConnectionErrorHandler(callback) {}
  32. /**
  33. * Creates an interface ptr and bind it to this instance.
  34. * @return {!mojo.InterfacePtr} The interface ptr.
  35. */
  36. createInterfacePtrAndBind() {}
  37. };
  38. mojo.InterfaceRequest = class {
  39. constructor() {
  40. /** @type {MojoHandle} */
  41. this.handle;
  42. }
  43. /**
  44. * Closes the message pipe. The object can no longer be bound to an
  45. * implementation.
  46. */
  47. close() {}
  48. };
  49. /** @interface */
  50. mojo.InterfacePtr = class {};
  51. mojo.InterfacePtrController = class {
  52. /**
  53. * Closes the message pipe. Messages can no longer be sent with this object.
  54. */
  55. reset() {}
  56. /** @param {function()} callback */
  57. setConnectionErrorHandler(callback) {}
  58. };
  59. mojo.Interface = class {
  60. constructor() {
  61. /** @type {string} */
  62. this.name;
  63. /** @type {number} */
  64. this.kVersion;
  65. /** @type {function()} */
  66. this.ptrClass;
  67. /** @type {function()} */
  68. this.proxyClass;
  69. /** @type {function()} */
  70. this.stubClass;
  71. /** @type {function()} */
  72. this.validateRequest;
  73. /** @type {function()} */
  74. this.validateResponse;
  75. }
  76. }
  77. /**
  78. * @param {!mojo.InterfacePtr} interfacePtr
  79. * @return {!mojo.InterfaceRequest}
  80. */
  81. mojo.makeRequest = function(interfacePtr) {};
  82. /** @const */
  83. mojo.internal = {};
  84. mojo.internal.InterfaceRemoteBase = class {
  85. /**
  86. * @param {MojoHandle=} opt_handle
  87. */
  88. constructor(opt_handle) {}
  89. /**
  90. * @param {!MojoHandle} handle
  91. */
  92. bindHandle(handle) {}
  93. unbind() {}
  94. /**
  95. * @param {number} ordinal
  96. * @param {!Object} paramStruct
  97. * @param {!Object} responseStruct
  98. * @param {!Array} args
  99. * @return {!Promise}
  100. */
  101. sendMessage(ordinal, paramStruct, responseStruct, args) {}
  102. };
  103. mojo.internal.CallbackRouter = class {
  104. constructor() {}
  105. /**
  106. * @param {number} id
  107. * @return {boolean}
  108. */
  109. removeListener(id) {}
  110. };
  111. mojo.internal.InterfaceTarget = class {
  112. constructor() {}
  113. /**
  114. * @param {number} ordinal
  115. * @param {!Object} paramStruct
  116. * @param {!Object} responseStruct
  117. * @param {!Function} handler
  118. */
  119. registerHandler(ordinal, paramStruct, responseStruct, handler) {}
  120. /**
  121. * @param {!MojoHandle} handle
  122. */
  123. bindHandle(handle) {}
  124. closeBindings() {}
  125. };
  126. mojo.internal.InterfaceCallbackTarget = class {
  127. /**
  128. * @param {!mojo.internal.CallbackRouter} callbackRouter
  129. */
  130. constructor(callbackRouter) {}
  131. /**
  132. * @param {!Function} listener
  133. * @return {number}
  134. */
  135. addListener(listener) {}
  136. /**
  137. * @param {number} id
  138. * @return {boolean}
  139. */
  140. removeListener(id) {}
  141. /**
  142. * @param {boolean} expectsResponse
  143. * @return {!Function}
  144. */
  145. createTargetHandler(expectsResponse) {}
  146. };
  147. mojo.internal.ConnectionErrorEventRouter = class {
  148. /**
  149. * @param {!Function} listener
  150. * @return {number} An ID which can be given to removeListener() to remove
  151. * this listener.
  152. */
  153. addListener(listener) {}
  154. /**
  155. * @param {number} id An ID returned by a prior call to addListener.
  156. * @return {boolean} True iff the identified listener was found and removed.
  157. */
  158. removeListener(id) {}
  159. };