Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsISupports.idl"
7
8
interface nsIFile;
9
interface nsISocketTransport;
10
interface nsIProxyInfo;
11
interface nsIRunnable;
12
13
%{C++
14
class nsASocketHandler;
15
struct PRFileDesc;
16
%}
17
18
[ptr] native PRFileDescPtr(PRFileDesc);
19
[ptr] native nsASocketHandlerPtr(nsASocketHandler);
20
21
[builtinclass, scriptable, uuid(ad56b25f-e6bb-4db3-9f7b-5b7db33fd2b1)]
22
interface nsISocketTransportService : nsISupports
23
{
24
/**
25
* Creates a transport for a specified host and port.
26
*
27
* @param aSocketTypes
28
* array of socket type strings. Empty array if using default
29
* socket type.
30
* @param aHost
31
* specifies the target hostname or IP address literal of the peer
32
* for this socket.
33
* @param aPort
34
* specifies the target port of the peer for this socket.
35
* @param aProxyInfo
36
* specifies the transport-layer proxy type to use. null if no
37
* proxy. used for communicating information about proxies like
38
* SOCKS (which are transparent to upper protocols).
39
*
40
* @see nsIProxiedProtocolHandler
41
* @see nsIProtocolProxyService::GetProxyInfo
42
*
43
* NOTE: this function can be called from any thread
44
*/
45
nsISocketTransport createTransport(in Array<ACString> aSocketTypes,
46
in AUTF8String aHost,
47
in long aPort,
48
in nsIProxyInfo aProxyInfo);
49
50
/**
51
* Create a transport built on a Unix domain socket, connecting to the
52
* given filename.
53
*
54
* Since Unix domain sockets are always local to the machine, they are
55
* not affected by the nsIIOService's 'offline' flag.
56
*
57
* On systems that don't support Unix domain sockets at all, this
58
* returns NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED.
59
*
60
* The system-level socket API may impose restrictions on the length of
61
* the filename that are stricter than those of the underlying
62
* filesystem. If the file name is too long, this returns
63
* NS_ERROR_FILE_NAME_TOO_LONG.
64
*
65
* The |aPath| parameter must specify an existing directory entry.
66
* Otherwise, this returns NS_ERROR_FILE_NOT_FOUND.
67
*
68
* The program must have search permission on all components of the
69
* path prefix of |aPath|, and read and write permission on |aPath|
70
* itself. Without such permission, this returns
71
* NS_ERROR_CONNECTION_REFUSED.
72
*
73
* The |aPath| parameter must refer to a unix-domain socket. Otherwise,
74
* this returns NS_ERROR_CONNECTION_REFUSED. (POSIX specifies
75
* ECONNREFUSED when "the target address was not listening for
76
* connections", and this is what Linux returns.)
77
*
78
* @param aPath
79
* The file name of the Unix domain socket to which we should
80
* connect.
81
*/
82
nsISocketTransport createUnixDomainTransport(in nsIFile aPath);
83
84
/**
85
* Create a transport built on a Unix domain socket that uses abstract
86
* address name.
87
*
88
* If abstract socket address isn't supported on System, this returns
89
* NS_ERROR_SOCKET_ADDRESS_NOT_SUPPORTED.
90
*
91
* @param aName
92
* The name of abstract socket adress of the Unix domain socket to
93
* which we should connect.
94
*/
95
nsISocketTransport
96
createUnixDomainAbstractAddressTransport(in ACString aName);
97
98
/**
99
* Adds a new socket to the list of controlled sockets.
100
*
101
* This will fail with the error code NS_ERROR_NOT_AVAILABLE if the maximum
102
* number of sockets is already reached.
103
* In this case, the notifyWhenCanAttachSocket method should be used.
104
*
105
* @param aFd
106
* Open file descriptor of the socket to control.
107
* @param aHandler
108
* Socket handler that will receive notifications when the socket is
109
* ready or detached.
110
*
111
* NOTE: this function may only be called from an event dispatch on the
112
* socket thread.
113
*/
114
[noscript] void attachSocket(in PRFileDescPtr aFd,
115
in nsASocketHandlerPtr aHandler);
116
117
/**
118
* if the number of sockets reaches the limit, then consumers can be
119
* notified when the number of sockets becomes less than the limit. the
120
* notification is asynchronous, delivered via the given nsIRunnable
121
* instance on the socket transport thread.
122
*
123
* @param aEvent
124
* Event that will receive the notification when a new socket can
125
* be attached
126
*
127
* NOTE: this function may only be called from an event dispatch on the
128
* socket thread.
129
*/
130
[noscript] void notifyWhenCanAttachSocket(in nsIRunnable aEvent);
131
};
132
133
[builtinclass, scriptable, uuid(c5204623-5b58-4a16-8b2e-67c34dd02e3f)]
134
interface nsIRoutedSocketTransportService : nsISocketTransportService
135
{
136
// use this instead of createTransport when you have a transport
137
// that distinguishes between origin and route (aka connection)
138
nsISocketTransport createRoutedTransport(in Array<ACString> aSocketTypes,
139
in AUTF8String aHost, // origin
140
in long aPort, // origin
141
in AUTF8String aHostRoute,
142
in long aPortRoute,
143
in nsIProxyInfo aProxyInfo);
144
};