Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: third_party/chrome/idl/socket.idl

Issue 12261015: Import chrome idl into third_party (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/chrome/idl/session_restore.json ('k') | third_party/chrome/idl/storage.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 namespace socket {
6 enum SocketType {
7 tcp,
8 udp
9 };
10
11 // The socket options.
12 dictionary CreateOptions {
13 };
14
15 dictionary CreateInfo {
16 // The id of the newly created socket.
17 long socketId;
18 };
19
20 callback CreateCallback = void (CreateInfo createInfo);
21
22 callback ConnectCallback = void (long result);
23
24 callback BindCallback = void (long result);
25
26 callback ListenCallback = void (long result);
27
28 dictionary AcceptInfo {
29 long resultCode;
30 // The id of the accepted socket.
31 long? socketId;
32 };
33
34 callback AcceptCallback = void (AcceptInfo acceptInfo);
35
36 dictionary ReadInfo {
37 // The resultCode returned from the underlying read() call.
38 long resultCode;
39
40 ArrayBuffer data;
41 };
42
43 callback ReadCallback = void (ReadInfo readInfo);
44
45 dictionary WriteInfo {
46 // The number of bytes sent, or a negative error code.
47 long bytesWritten;
48 };
49
50 callback WriteCallback = void (WriteInfo writeInfo);
51
52 dictionary RecvFromInfo {
53 // The resultCode returned from the underlying recvfrom() call.
54 long resultCode;
55
56 ArrayBuffer data;
57
58 // The address of the remote machine.
59 DOMString address;
60
61 long port;
62 };
63
64 dictionary SocketInfo {
65 // The type of the passed socket. This will be <code>tcp</code> or
66 // <code>udp</code>.
67 SocketType socketType;
68
69 // Whether or not the underlying socket is connected.
70 //
71 // For <code>tcp</code> sockets, this will remain true even if the remote
72 // peer has disconnected. Reading or writing to the socket may then result
73 // in an error, hinting that this socket should be disconnected via
74 // <code>disconnect()</code>.
75 //
76 // For <code>udp</code> sockets, this just represents whether a default
77 // remote address has been specified for reading and writing packets.
78 boolean connected;
79
80 // If the underlying socket is connected, contains the IPv4/6 address of
81 // the peer.
82 DOMString? peerAddress;
83
84 // If the underlying socket is connected, contains the port of the
85 // connected peer.
86 long? peerPort;
87
88 // If the underlying socket is bound or connected, contains its local
89 // IPv4/6 address.
90 DOMString? localAddress;
91
92 // If the underlying socket is bound or connected, contains its local port.
93 long? localPort;
94 };
95
96 dictionary NetworkInterface {
97 // The underlying name of the adapter. On *nix, this will typically be
98 // "eth0", "lo", etc.
99 DOMString name;
100
101 // The available IPv4/6 address.
102 DOMString address;
103 };
104
105 callback RecvFromCallback = void (RecvFromInfo recvFromInfo);
106
107 callback SendToCallback = void (WriteInfo writeInfo);
108
109 callback SetKeepAliveCallback = void (boolean result);
110
111 callback SetNoDelayCallback = void (boolean result);
112
113 callback GetInfoCallback = void (SocketInfo result);
114
115 callback GetNetworkCallback = void (NetworkInterface[] result);
116
117 interface Functions {
118 // Creates a socket of the specified type that will connect to the specified
119 // remote machine.
120 // |type| : The type of socket to create. Must be <code>tcp</code> or
121 // <code>udp</code>.
122 // |options| : The socket options.
123 // |callback| : Called when the socket has been created.
124 static void create(SocketType type,
125 optional CreateOptions options,
126 CreateCallback callback);
127
128 // Destroys the socket. Each socket created should be destroyed after use.
129 // |socketId| : The socketId.
130 static void destroy(long socketId);
131
132 // Connects the socket to the remote machine (for a <code>tcp</code>
133 // socket). For a <code>udp</code> socket, this sets the default address
134 // which packets are sent to and read from for <code>read()</code>
135 // and <code>write()</code> calls.
136 // |socketId| : The socketId.
137 // |hostname| : The hostname or IP address of the remote machine.
138 // |port| : The port of the remote machine.
139 // |callback| : Called when the connection attempt is complete.
140 static void connect(long socketId,
141 DOMString hostname,
142 long port,
143 ConnectCallback callback);
144
145 // Binds the local address for socket. Currently, it does not support
146 // TCP socket.
147 // |socketId| : The socketId.
148 // |address| : The address of the local machine.
149 // |port| : The port of the local machine.
150 // |callback| : Called when the bind attempt is complete.
151 static void bind(long socketId,
152 DOMString address,
153 long port,
154 BindCallback callback);
155
156 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a
157 // non-operation but is safe to call.
158 // |socketId| : The socketId.
159 static void disconnect(long socketId);
160
161 // Reads data from the given connected socket.
162 // |socketId| : The socketId.
163 // |bufferSize| : The read buffer size.
164 // |callback| : Delivers data that was available to be read without
165 // blocking.
166 static void read(long socketId,
167 optional long bufferSize,
168 ReadCallback callback);
169
170 // Writes data on the given connected socket.
171 // |socketId| : The socketId.
172 // |data| : The data to write.
173 // |callback| : Called when the write operation completes without blocking
174 // or an error occurs.
175 static void write(long socketId,
176 ArrayBuffer data,
177 WriteCallback callback);
178
179 // Receives data from the given UDP socket.
180 // |socketId| : The socketId.
181 // |bufferSize| : The receive buffer size.
182 // |callback| : Returns result of the recvFrom operation.
183 static void recvFrom(long socketId,
184 optional long bufferSize,
185 RecvFromCallback callback);
186
187 // Sends data on the given UDP socket to the given address and port.
188 // |socketId| : The socketId.
189 // |data| : The data to write.
190 // |address| : The address of the remote machine.
191 // |port| : The port of the remote machine.
192 // |callback| : Called when the send operation completes without blocking
193 // or an error occurs.
194 static void sendTo(long socketId,
195 ArrayBuffer data,
196 DOMString address,
197 long port,
198 SendToCallback callback);
199
200 // This method applies to TCP sockets only.
201 // Listens for connections on the specified port and address. This
202 // effectively makes this a server socket, and client socket
203 // functions (connect, read, write) can no longer be used on this socket.
204 // |socketId| : The socketId.
205 // |address| : The address of the local machine.
206 // |port| : The port of the local machine.
207 // |backlog| : Length of the socket's listen queue.
208 static void listen(long socketId,
209 DOMString address,
210 long port,
211 optional long backlog,
212 ListenCallback callback);
213
214 // This method applies to TCP sockets only.
215 // Registers a callback function to be called when a connection is
216 // accepted on this listening server socket. Listen must be called first.
217 // If there is already an active accept callback, this callback will be
218 // invoked immediately with an error as the resultCode.
219 // |socketId| : The socketId.
220 // |callback| : The callback is invoked when a new socket is accepted.
221 static void accept(long socketId,
222 AcceptCallback callback);
223
224 // Enables or disables the keep-alive functionality for a TCP connection.
225 // |socketId| : The socketId.
226 // |enable| : If true, enable keep-alive functionality.
227 // |delay| : Set the delay seconds between the last data packet received
228 // and the first keepalive probe. Default is 0.
229 // |callback| : Called when the setKeepAlive attempt is complete.
230 static void setKeepAlive(long socketId,
231 boolean enable,
232 optional long delay,
233 SetKeepAliveCallback callback);
234
235 // Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
236 // algorithm will be disabled when <code>TCP_NODELAY</code> is set.
237 // |socketId| : The socketId.
238 // |noDelay| : If true, disables Nagle's algorithm.
239 // |callback| : Called when the setNoDelay attempt is complete.
240 static void setNoDelay(long socketId,
241 boolean noDelay,
242 SetNoDelayCallback callback);
243
244 // Retrieves the state of the given socket.
245 // |socketId| : The socketId.
246 // |callback| : Called when the state is available.
247 static void getInfo(long socketId,
248 GetInfoCallback callback);
249
250 // Retrieves information about local adapters on this system.
251 // |callback| : Called when local adapter information is available.
252 static void getNetworkList(GetNetworkCallback callback);
253 };
254
255 };
OLDNEW
« no previous file with comments | « third_party/chrome/idl/session_restore.json ('k') | third_party/chrome/idl/storage.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698