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
/* 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"

interface nsIDOMTCPSocket;
interface nsIDOMTCPServerSocket;
interface nsITCPServerSocketParent;
interface nsITCPSocketIntermediary;

// Interface required to allow the TCP socket object (TCPSocket.js) in the
// parent process to talk to the parent IPC actor, TCPSocketParent, which
// is written in C++.
[scriptable, uuid(6f040bf0-6852-11e3-949a-0800200c9a66)]
interface nsITCPSocketParent : nsISupports
{
  [implicit_jscontext] void initJS(in jsval intermediary);

  // Trigger a callback in the content process for |type|, providing a serialized
  // argument of |data|, and update the child's readyState value with the given
  // values.
  //
  // @param type
  //        Event type: 'onopen', 'ondata', 'onerror' or 'onclose'. 'odrain' is
  //        controlled by child.
  // @param data
  //        Serialized data that is passed to event handler.
  // @param readyState
  //        Current ready state.
  [implicit_jscontext] void sendEvent(in DOMString type,
                                      in jsval data,
                                      in DOMString readyState);

  // Initialize a parent socket object. It is called from the parent side socket,
  // which is generated in accepting any open request on the parent side.
  // The socket after being initialized will be established.
  //
  // @param socket
  //        The socket on the parent side.
  // @param intermediary
  //        Intermediate class object. See nsITCPSocketIntermediary.
  [implicit_jscontext] void setSocketAndIntermediary(in nsIDOMTCPSocket socket,
                                                     in nsITCPSocketIntermediary intermediary);

  // When parent's buffered amount is updated and it wants to inform child to
  // update the bufferedAmount as well.
  //
  // @param bufferedAmount
  //        The new value of bufferedAmount that is going to be set to child's
  //        bufferedAmount.
  // @param trackingNumber
  //        Parent's current tracking number, reflecting the number of calls to
  //        send() on the child process. This number is sent back to the child
  //        to make sure the bufferedAmount updated on the child will correspond
  //        to the latest call of send().
  void sendUpdateBufferedAmount(in uint32_t bufferedAmount, in uint32_t trackingNumber);

  readonly attribute DOMString host;
  readonly attribute unsigned short port;
};

// Intermediate class to handle sending multiple possible data types
// and kicking off the chrome process socket object's connection.
// This interface is the bridge of TCPSocketParent, which is written in C++,
// and TCPSocket, which is written in Javascript. TCPSocketParentIntermediary
// implements nsITCPSocketIntermediary in Javascript.
[scriptable, uuid(c434224a-dbb7-4869-8b2b-e49cee990e85)]
interface nsITCPSocketIntermediary : nsISupports {
  // Open the connection to the server with the given parameters
  nsIDOMTCPSocket open(in nsITCPSocketParent parent,
                       in DOMString host, in unsigned short port,
                       in boolean useSSL, in DOMString binaryType,
                       in unsigned long appId);

  // Listen on a port
  nsIDOMTCPServerSocket listen(in nsITCPServerSocketParent parent,
                               in unsigned short port, in unsigned short backlog,
                               in DOMString binaryType);

  // Called when received a child request to send a string.
  void onRecvSendString(in DOMString data, in uint32_t trackingNumber);

  // Called when received a child request to send an array buffer.
  void onRecvSendArrayBuffer(in jsval data, in uint32_t trackingNumber);
};