michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "domstubs.idl" michael@0: michael@0: interface nsIDOMTCPSocket; michael@0: interface nsIDOMTCPServerSocket; michael@0: interface nsITCPServerSocketParent; michael@0: interface nsITCPSocketIntermediary; michael@0: michael@0: // Interface required to allow the TCP socket object (TCPSocket.js) in the michael@0: // parent process to talk to the parent IPC actor, TCPSocketParent, which michael@0: // is written in C++. michael@0: [scriptable, uuid(868662a4-681c-4b89-9f02-6fe5b7ace265)] michael@0: interface nsITCPSocketParent : nsISupports michael@0: { michael@0: [implicit_jscontext] void initJS(in jsval intermediary); michael@0: michael@0: // Trigger a callback in the content process for |type|, providing a serialized michael@0: // argument of |data|, and update the child's readyState value with the given michael@0: // values. michael@0: // michael@0: // @param type michael@0: // Event type: 'onopen', 'ondata', 'onerror' or 'onclose'. 'odrain' is michael@0: // controlled by child. michael@0: // @param data michael@0: // Serialized data that is passed to event handler. michael@0: // @param readyState michael@0: // Current ready state. michael@0: [implicit_jscontext] void sendEvent(in DOMString type, michael@0: in jsval data, michael@0: in DOMString readyState); michael@0: michael@0: // Initialize a parent socket object. It is called from the parent side socket, michael@0: // which is generated in accepting any open request on the parent side. michael@0: // The socket after being initialized will be established. michael@0: // michael@0: // @param socket michael@0: // The socket on the parent side. michael@0: // @param intermediary michael@0: // Intermediate class object. See nsITCPSocketIntermediary. michael@0: [implicit_jscontext] void setSocketAndIntermediary(in nsIDOMTCPSocket socket, michael@0: in nsITCPSocketIntermediary intermediary); michael@0: michael@0: // When parent's buffered amount is updated and it wants to inform child to michael@0: // update the bufferedAmount as well. michael@0: // michael@0: // @param bufferedAmount michael@0: // The new value of bufferedAmount that is going to be set to child's michael@0: // bufferedAmount. michael@0: // @param trackingNumber michael@0: // Parent's current tracking number, reflecting the number of calls to michael@0: // send() on the child process. This number is sent back to the child michael@0: // to make sure the bufferedAmount updated on the child will correspond michael@0: // to the latest call of send(). michael@0: void sendUpdateBufferedAmount(in uint32_t bufferedAmount, in uint32_t trackingNumber); michael@0: }; michael@0: michael@0: // Intermediate class to handle sending multiple possible data types michael@0: // and kicking off the chrome process socket object's connection. michael@0: // This interface is the bridge of TCPSocketParent, which is written in C++, michael@0: // and TCPSocket, which is written in Javascript. TCPSocketParentIntermediary michael@0: // implements nsITCPSocketIntermediary in Javascript. michael@0: [scriptable, uuid(c434224a-dbb7-4869-8b2b-e49cee990e85)] michael@0: interface nsITCPSocketIntermediary : nsISupports { michael@0: // Open the connection to the server with the given parameters michael@0: nsIDOMTCPSocket open(in nsITCPSocketParent parent, michael@0: in DOMString host, in unsigned short port, michael@0: in boolean useSSL, in DOMString binaryType, michael@0: in unsigned long appId); michael@0: michael@0: // Listen on a port michael@0: nsIDOMTCPServerSocket listen(in nsITCPServerSocketParent parent, michael@0: in unsigned short port, in unsigned short backlog, michael@0: in DOMString binaryType); michael@0: michael@0: // Called when received a child request to send a string. michael@0: void onRecvSendString(in DOMString data, in uint32_t trackingNumber); michael@0: michael@0: // Called when received a child request to send an array buffer. michael@0: void onRecvSendArrayBuffer(in jsval data, in uint32_t trackingNumber); michael@0: };