gecko-dev/dom/network/interfaces/nsITCPSocketParent.idl
Andrew Sutherland 9a4520d5ff Bug 1087145 - Move mozTCPSocket/TCPSocket unit tests from xpcshell tests to mochitest-plain tests. r=jdm
Most of the TCPSocket and TCPServerSocket coverage was implemented exclusively
in Chrome-privileged xpcshell tests.  This failed to provide coverage for the
key use case of content-privileged code using TCPSocket.

This cleans up the test implementation and migrates them to mochitests.
Coverage is improved as evidenced by two tested TCPServerSocket issues that were
addressed in this patch:
- ArrayBuffers weren't being created in the content page's context, so
  exceptions would be thrown when accessed.
- 'drain' notifications were not being hooked up.

The following fix that lacks coverage that notices the fix was implemented:
- TCPServerSocket now properly propagates the appId for network usage tracking.
2014-10-29 22:03:54 -04:00

88 lines
3.8 KiB
Plaintext

/* 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,
in unsigned long appId);
// 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);
};