netwerk/base/public/nsISocketTransportService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsISocketTransportService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsIFile;
    1.12 +interface nsISocketTransport;
    1.13 +interface nsIProxyInfo;
    1.14 +interface nsIRunnable;
    1.15 +
    1.16 +%{C++
    1.17 +class nsASocketHandler;
    1.18 +struct PRFileDesc;
    1.19 +%}
    1.20 +
    1.21 +[ptr] native PRFileDescPtr(PRFileDesc);
    1.22 +[ptr] native nsASocketHandlerPtr(nsASocketHandler);
    1.23 +
    1.24 +[scriptable, uuid(ad56b25f-e6bb-4db3-9f7b-5b7db33fd2b1)]
    1.25 +interface nsISocketTransportService : nsISupports 
    1.26 +{
    1.27 +    /**
    1.28 +     * Creates a transport for a specified host and port.
    1.29 +     *
    1.30 +     * @param aSocketTypes
    1.31 +     *        array of socket type strings.  null if using default socket type.
    1.32 +     * @param aTypeCount
    1.33 +     *        specifies length of aSocketTypes.
    1.34 +     * @param aHost
    1.35 +     *        specifies the target hostname or IP address literal of the peer
    1.36 +     *        for this socket.
    1.37 +     * @param aPort
    1.38 +     *        specifies the target port of the peer for this socket.
    1.39 +     * @param aProxyInfo
    1.40 +     *        specifies the transport-layer proxy type to use.  null if no
    1.41 +     *        proxy.  used for communicating information about proxies like
    1.42 +     *        SOCKS (which are transparent to upper protocols).
    1.43 +     *
    1.44 +     * @see nsIProxiedProtocolHandler
    1.45 +     * @see nsIProtocolProxyService::GetProxyInfo
    1.46 +     *
    1.47 +     * NOTE: this function can be called from any thread
    1.48 +     */
    1.49 +    nsISocketTransport createTransport([array, size_is(aTypeCount)]
    1.50 +                                       in string aSocketTypes,
    1.51 +                                       in unsigned long aTypeCount,
    1.52 +                                       in AUTF8String aHost,
    1.53 +                                       in long aPort,
    1.54 +                                       in nsIProxyInfo aProxyInfo);
    1.55 +
    1.56 +    /**
    1.57 +     * Create a transport built on a Unix domain socket, connecting to the
    1.58 +     * given filename.
    1.59 +     *
    1.60 +     * Since Unix domain sockets are always local to the machine, they are
    1.61 +     * not affected by the nsIIOService's 'offline' flag.
    1.62 +     *
    1.63 +     * On systems that don't support Unix domain sockets at all, this
    1.64 +     * returns NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED.
    1.65 +     *
    1.66 +     * The system-level socket API may impose restrictions on the length of
    1.67 +     * the filename that are stricter than those of the underlying
    1.68 +     * filesystem. If the file name is too long, this returns
    1.69 +     * NS_ERROR_FILE_NAME_TOO_LONG.
    1.70 +     *
    1.71 +     * The |aPath| parameter must specify an existing directory entry.
    1.72 +     * Otherwise, this returns NS_ERROR_FILE_NOT_FOUND.
    1.73 +     *
    1.74 +     * The program must have search permission on all components of the
    1.75 +     * path prefix of |aPath|, and read and write permission on |aPath|
    1.76 +     * itself. Without such permission, this returns
    1.77 +     * NS_ERROR_CONNECTION_REFUSED.
    1.78 +     *
    1.79 +     * The |aPath| parameter must refer to a unix-domain socket. Otherwise,
    1.80 +     * this returns NS_ERROR_CONNECTION_REFUSED. (POSIX specifies
    1.81 +     * ECONNREFUSED when "the target address was not listening for
    1.82 +     * connections", and this is what Linux returns.)
    1.83 +     *
    1.84 +     * @param aPath
    1.85 +     *        The file name of the Unix domain socket to which we should
    1.86 +     *        connect.
    1.87 +     */
    1.88 +    nsISocketTransport createUnixDomainTransport(in nsIFile aPath);
    1.89 +
    1.90 +    /**
    1.91 +     * Adds a new socket to the list of controlled sockets.
    1.92 +     *
    1.93 +     * This will fail with the error code NS_ERROR_NOT_AVAILABLE if the maximum
    1.94 +     * number of sockets is already reached.
    1.95 +     * In this case, the notifyWhenCanAttachSocket method should be used.
    1.96 +     *
    1.97 +     * @param aFd
    1.98 +     *        Open file descriptor of the socket to control.
    1.99 +     * @param aHandler
   1.100 +     *        Socket handler that will receive notifications when the socket is
   1.101 +     *        ready or detached.
   1.102 +     *
   1.103 +     * NOTE: this function may only be called from an event dispatch on the
   1.104 +     *       socket thread.
   1.105 +     */
   1.106 +    [noscript] void attachSocket(in PRFileDescPtr aFd,
   1.107 +                                 in nsASocketHandlerPtr aHandler);
   1.108 +
   1.109 +    /**
   1.110 +     * if the number of sockets reaches the limit, then consumers can be
   1.111 +     * notified when the number of sockets becomes less than the limit.  the
   1.112 +     * notification is asynchronous, delivered via the given nsIRunnable
   1.113 +     * instance on the socket transport thread.
   1.114 +     *
   1.115 +     * @param aEvent
   1.116 +     *        Event that will receive the notification when a new socket can
   1.117 +     *        be attached
   1.118 +     *
   1.119 +     * NOTE: this function may only be called from an event dispatch on the
   1.120 +     *       socket thread.
   1.121 +     */
   1.122 +    [noscript] void notifyWhenCanAttachSocket(in nsIRunnable aEvent);
   1.123 +};

mercurial