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