DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (d1ed7de67f5a)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "domstubs.idl"
#include "nsITCPSocketChild.idl"

// Bug 797561 - Expose a server tcp socket API to web applications
/**
 * nsIDOMTCPServerSocket
 *
 * An interface to a server socket that can accept incoming connections for gaia apps.
 */
[scriptable, uuid(821638a1-5327-416d-8031-668764f2ec04)]
interface nsIDOMTCPServerSocket : nsISupports
{
  /**
   * The port of this server socket object.
   */
  readonly attribute unsigned short localPort;

  /**
   * The onconnect event handler is called when a client connection is accepted.
   * The data attribute of the event passed to the onconnect handler will be a TCPSocket
   * instance, which is used for communication between client and server. 
   */
  attribute jsval onconnect;

  /**
   * The onerror handler will be called when the listen of a server socket is aborted.
   * The data attribute of the event passed to the onerror handler will have a
   * description of the kind of error.
   */
  attribute jsval onerror;

  /**
   * Close the server socket.
   */
  void close();
};

/**
 * Internal interfaces for use in cross-process server-socket implementation.
 * Needed to account for multiple possible types that can be provided to
 * the socket callbacks as arguments.
 *
 * These interfaces are for calling each method from the server socket object
 * on the parent and child side for an IPC protocol implementation.
 */

[scriptable, uuid(b64b1e68-4efa-497c-b0d8-69f067ad5ec8)]
interface nsITCPServerSocketInternal : nsISupports 
{
  /**
   * Initialization after creating a TCP server socket object.
   *
   * @param windowVal
   *        An object to create ArrayBuffer for this window. See Bug 831107.
   */
  void init(in jsval windowVal);

  /** 
   * Listen on a port
   *
   * @param localPort 
   *        The port of the server socket. Pass -1 to indicate no preference,
   *        and a port will be selected automatically.
   * @param options 
   *        An object specifying one or more parameters which
   *        determine the details of the socket.
   *
   *        binaryType: "arraybuffer" to use UInt8 array
   *        instances in the ondata callback and as the argument
   *        to send. Defaults to "string", to use JavaScript strings.
   * @param backlog 
   *        The maximum length the queue of pending connections may grow to.
   *        This parameter may be silently limited by the operating system.
   *        Pass -1 to use the default value.
   */
  void listen(in unsigned short localPort, in jsval options, in unsigned short backlog);

  /**
   * Listener for receiving an accepted socket.
   */
  void callListenerAccept(in nsITCPSocketChild socketChild);

  /**
   * Listener for handling an error caused in chrome process.
   */
  void callListenerError(in DOMString message, in DOMString filename,
                         in uint32_t lineNumber, in uint32_t columnNumber);
};