Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "domstubs.idl" |
michael@0 | 6 | |
michael@0 | 7 | interface nsIDOMTCPSocket; |
michael@0 | 8 | interface nsIDOMTCPServerSocket; |
michael@0 | 9 | interface nsITCPServerSocketParent; |
michael@0 | 10 | interface nsITCPSocketIntermediary; |
michael@0 | 11 | |
michael@0 | 12 | // Interface required to allow the TCP socket object (TCPSocket.js) in the |
michael@0 | 13 | // parent process to talk to the parent IPC actor, TCPSocketParent, which |
michael@0 | 14 | // is written in C++. |
michael@0 | 15 | [scriptable, uuid(868662a4-681c-4b89-9f02-6fe5b7ace265)] |
michael@0 | 16 | interface nsITCPSocketParent : nsISupports |
michael@0 | 17 | { |
michael@0 | 18 | [implicit_jscontext] void initJS(in jsval intermediary); |
michael@0 | 19 | |
michael@0 | 20 | // Trigger a callback in the content process for |type|, providing a serialized |
michael@0 | 21 | // argument of |data|, and update the child's readyState value with the given |
michael@0 | 22 | // values. |
michael@0 | 23 | // |
michael@0 | 24 | // @param type |
michael@0 | 25 | // Event type: 'onopen', 'ondata', 'onerror' or 'onclose'. 'odrain' is |
michael@0 | 26 | // controlled by child. |
michael@0 | 27 | // @param data |
michael@0 | 28 | // Serialized data that is passed to event handler. |
michael@0 | 29 | // @param readyState |
michael@0 | 30 | // Current ready state. |
michael@0 | 31 | [implicit_jscontext] void sendEvent(in DOMString type, |
michael@0 | 32 | in jsval data, |
michael@0 | 33 | in DOMString readyState); |
michael@0 | 34 | |
michael@0 | 35 | // Initialize a parent socket object. It is called from the parent side socket, |
michael@0 | 36 | // which is generated in accepting any open request on the parent side. |
michael@0 | 37 | // The socket after being initialized will be established. |
michael@0 | 38 | // |
michael@0 | 39 | // @param socket |
michael@0 | 40 | // The socket on the parent side. |
michael@0 | 41 | // @param intermediary |
michael@0 | 42 | // Intermediate class object. See nsITCPSocketIntermediary. |
michael@0 | 43 | [implicit_jscontext] void setSocketAndIntermediary(in nsIDOMTCPSocket socket, |
michael@0 | 44 | in nsITCPSocketIntermediary intermediary); |
michael@0 | 45 | |
michael@0 | 46 | // When parent's buffered amount is updated and it wants to inform child to |
michael@0 | 47 | // update the bufferedAmount as well. |
michael@0 | 48 | // |
michael@0 | 49 | // @param bufferedAmount |
michael@0 | 50 | // The new value of bufferedAmount that is going to be set to child's |
michael@0 | 51 | // bufferedAmount. |
michael@0 | 52 | // @param trackingNumber |
michael@0 | 53 | // Parent's current tracking number, reflecting the number of calls to |
michael@0 | 54 | // send() on the child process. This number is sent back to the child |
michael@0 | 55 | // to make sure the bufferedAmount updated on the child will correspond |
michael@0 | 56 | // to the latest call of send(). |
michael@0 | 57 | void sendUpdateBufferedAmount(in uint32_t bufferedAmount, in uint32_t trackingNumber); |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | // Intermediate class to handle sending multiple possible data types |
michael@0 | 61 | // and kicking off the chrome process socket object's connection. |
michael@0 | 62 | // This interface is the bridge of TCPSocketParent, which is written in C++, |
michael@0 | 63 | // and TCPSocket, which is written in Javascript. TCPSocketParentIntermediary |
michael@0 | 64 | // implements nsITCPSocketIntermediary in Javascript. |
michael@0 | 65 | [scriptable, uuid(c434224a-dbb7-4869-8b2b-e49cee990e85)] |
michael@0 | 66 | interface nsITCPSocketIntermediary : nsISupports { |
michael@0 | 67 | // Open the connection to the server with the given parameters |
michael@0 | 68 | nsIDOMTCPSocket open(in nsITCPSocketParent parent, |
michael@0 | 69 | in DOMString host, in unsigned short port, |
michael@0 | 70 | in boolean useSSL, in DOMString binaryType, |
michael@0 | 71 | in unsigned long appId); |
michael@0 | 72 | |
michael@0 | 73 | // Listen on a port |
michael@0 | 74 | nsIDOMTCPServerSocket listen(in nsITCPServerSocketParent parent, |
michael@0 | 75 | in unsigned short port, in unsigned short backlog, |
michael@0 | 76 | in DOMString binaryType); |
michael@0 | 77 | |
michael@0 | 78 | // Called when received a child request to send a string. |
michael@0 | 79 | void onRecvSendString(in DOMString data, in uint32_t trackingNumber); |
michael@0 | 80 | |
michael@0 | 81 | // Called when received a child request to send an array buffer. |
michael@0 | 82 | void onRecvSendArrayBuffer(in jsval data, in uint32_t trackingNumber); |
michael@0 | 83 | }; |