Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | #include "nsITCPSocketChild.idl" |
michael@0 | 7 | |
michael@0 | 8 | // Bug 797561 - Expose a server tcp socket API to web applications |
michael@0 | 9 | /** |
michael@0 | 10 | * nsIDOMTCPServerSocket |
michael@0 | 11 | * |
michael@0 | 12 | * An interface to a server socket that can accept incoming connections for gaia apps. |
michael@0 | 13 | */ |
michael@0 | 14 | [scriptable, uuid(821638a1-5327-416d-8031-668764f2ec04)] |
michael@0 | 15 | interface nsIDOMTCPServerSocket : nsISupports |
michael@0 | 16 | { |
michael@0 | 17 | /** |
michael@0 | 18 | * The port of this server socket object. |
michael@0 | 19 | */ |
michael@0 | 20 | readonly attribute unsigned short localPort; |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * The onconnect event handler is called when a client connection is accepted. |
michael@0 | 24 | * The data attribute of the event passed to the onconnect handler will be a TCPSocket |
michael@0 | 25 | * instance, which is used for communication between client and server. |
michael@0 | 26 | */ |
michael@0 | 27 | attribute jsval onconnect; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * The onerror handler will be called when the listen of a server socket is aborted. |
michael@0 | 31 | * The data attribute of the event passed to the onerror handler will have a |
michael@0 | 32 | * description of the kind of error. |
michael@0 | 33 | */ |
michael@0 | 34 | attribute jsval onerror; |
michael@0 | 35 | |
michael@0 | 36 | /** |
michael@0 | 37 | * Close the server socket. |
michael@0 | 38 | */ |
michael@0 | 39 | void close(); |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * Internal interfaces for use in cross-process server-socket implementation. |
michael@0 | 44 | * Needed to account for multiple possible types that can be provided to |
michael@0 | 45 | * the socket callbacks as arguments. |
michael@0 | 46 | * |
michael@0 | 47 | * These interfaces are for calling each method from the server socket object |
michael@0 | 48 | * on the parent and child side for an IPC protocol implementation. |
michael@0 | 49 | */ |
michael@0 | 50 | |
michael@0 | 51 | [scriptable, uuid(b64b1e68-4efa-497c-b0d8-69f067ad5ec8)] |
michael@0 | 52 | interface nsITCPServerSocketInternal : nsISupports |
michael@0 | 53 | { |
michael@0 | 54 | /** |
michael@0 | 55 | * Initialization after creating a TCP server socket object. |
michael@0 | 56 | * |
michael@0 | 57 | * @param windowVal |
michael@0 | 58 | * An object to create ArrayBuffer for this window. See Bug 831107. |
michael@0 | 59 | */ |
michael@0 | 60 | void init(in jsval windowVal); |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Listen on a port |
michael@0 | 64 | * |
michael@0 | 65 | * @param localPort |
michael@0 | 66 | * The port of the server socket. Pass -1 to indicate no preference, |
michael@0 | 67 | * and a port will be selected automatically. |
michael@0 | 68 | * @param options |
michael@0 | 69 | * An object specifying one or more parameters which |
michael@0 | 70 | * determine the details of the socket. |
michael@0 | 71 | * |
michael@0 | 72 | * binaryType: "arraybuffer" to use UInt8 array |
michael@0 | 73 | * instances in the ondata callback and as the argument |
michael@0 | 74 | * to send. Defaults to "string", to use JavaScript strings. |
michael@0 | 75 | * @param backlog |
michael@0 | 76 | * The maximum length the queue of pending connections may grow to. |
michael@0 | 77 | * This parameter may be silently limited by the operating system. |
michael@0 | 78 | * Pass -1 to use the default value. |
michael@0 | 79 | */ |
michael@0 | 80 | void listen(in unsigned short localPort, in jsval options, in unsigned short backlog); |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * Listener for receiving an accepted socket. |
michael@0 | 84 | */ |
michael@0 | 85 | void callListenerAccept(in nsITCPSocketChild socketChild); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Listener for handling an error caused in chrome process. |
michael@0 | 89 | */ |
michael@0 | 90 | void callListenerError(in DOMString message, in DOMString filename, |
michael@0 | 91 | in uint32_t lineNumber, in uint32_t columnNumber); |
michael@0 | 92 | }; |