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

Side by Side Diff: ppapi/c/extensions/dev/ppb_ext_socket_dev.h

Issue 13490003: Apps v2 in Pepper: Add C/C++ definition for chrome.socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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
OLDNEW
(Empty)
1 /* Copyright (c) 2013 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
6 /* From extensions/dev/ppb_ext_socket_dev.idl,
7 * modified Tue Apr 02 16:04:00 2013.
8 */
9
10 #ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_
11 #define PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_
12
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_macros.h"
17 #include "ppapi/c/pp_stdint.h"
18 #include "ppapi/c/pp_var.h"
19
20 #define PPB_EXT_SOCKET_DEV_INTERFACE_0_1 "PPB_Ext_Socket(Dev);0.1"
21 #define PPB_EXT_SOCKET_DEV_INTERFACE PPB_EXT_SOCKET_DEV_INTERFACE_0_1
22
23 /**
24 * @file
25 * This file defines the Pepper equivalent of the <code>chrome.socket</code>
26 * extension API.
27 */
28
29
30 /**
31 * @addtogroup Typedefs
32 * @{
33 */
34 /**
35 * A string <code>PP_Var</code> which has one of the following values:
36 * - "tcp"
37 * - "udp"
38 */
39 typedef struct PP_Var PP_Ext_Socket_SocketType_Dev;
40
41 /**
42 * A dictionary <code>PP_Var</code>.
43 */
44 typedef struct PP_Var PP_Ext_Socket_CreateOptions_Dev;
45
46 /**
47 * A dictionary <code>PP_Var</code> which contains
48 * - "socketId" : integer <code>PP_Var</code>
49 * The id of the newly created socket.
50 */
51 typedef struct PP_Var PP_Ext_Socket_CreateInfo_Dev;
52
53 /**
54 * A dictionary <code>PP_Var</code> which contains
55 * - "resultCode" : integer <code>PP_Var</code>
56 * - "socketId" : integer or undefined <code>PP_Var</code>
57 * The id of the accepted socket.
58 */
59 typedef struct PP_Var PP_Ext_Socket_AcceptInfo_Dev;
60
61 /**
62 * A dictionary <code>PP_Var</code> which contains
63 * - "resultCode" : integer <code>PP_Var</code>
64 * The resultCode returned from the underlying read() call.
65 * - "data" : array buffer <code>PP_Var</code>
66 */
67 typedef struct PP_Var PP_Ext_Socket_ReadInfo_Dev;
68
69 /**
70 * A dictionary <code>PP_Var</code> which contains
71 * - "bytesWritten" : integer <code>PP_Var</code>
72 * The number of bytes sent, or a negative error code.
73 */
74 typedef struct PP_Var PP_Ext_Socket_WriteInfo_Dev;
75
76 /**
77 * A dictionary <code>PP_Var</code> which contains
78 * - "resultCode" : integer <code>PP_Var</code>
79 * The resultCode returned from the underlying recvfrom() call.
80 * - "data": array buffer <code>PP_Var</code>
81 * - "address": string <code>PP_Var</code>
82 * The address of the remote machine.
83 * - "port": integer <code>PP_Var</code>
84 */
85 typedef struct PP_Var PP_Ext_Socket_RecvFromInfo_Dev;
86
87 /**
88 * A dictionary <code>PP_Var</code> which contains
89 * - "socketType" : string <code>PP_Var</code> which matches the description of
90 * <code>PP_Ext_Socket_SocketType_Dev</code>
91 * The type of the passed socket. This will be <code>tcp</code> or
92 * <code>udp</code>.
93 * - "connected" : boolean <code>PP_Var</code>
94 * Whether or not the underlying socket is connected.
95 *
96 * For <code>tcp</code> sockets, this will remain true even if the remote peer
97 * has disconnected. Reading or writing to the socket may then result in an
98 * error, hinting that this socket should be disconnected via
99 * <code>Disconnect()</code>.
100 *
101 * For <code>udp</code> sockets, this just represents whether a default remote
102 * address has been specified for reading and writing packets.
103 * - "peerAddress" : string or undefined <code>PP_Var</code>
104 * If the underlying socket is connected, contains the IPv4/6 address of the
105 * peer.
106 * - "peerPort" : integer or undefined <code>PP_Var</code>
107 * If the underlying socket is connected, contains the port of the connected
108 * peer.
109 * - "localAddress" : string or undefined <code>PP_Var</code>
110 * If the underlying socket is bound or connected, contains its local IPv4/6
111 * address.
112 * - "localPort" : integer or undefined <code>PP_Var</code>
113 * If the underlying socket is bound or connected, contains its local port.
114 */
115 typedef struct PP_Var PP_Ext_Socket_SocketInfo_Dev;
116
117 /**
118 * A dictionary <code>PP_Var</code> which contains
119 * - "name" : string <code>PP_Var</code>
120 * The underlying name of the adapter. On *nix, this will typically be "eth0",
121 * "lo", etc.
122 * - "address": string <code>PP_Var</code>
123 * The available IPv4/6 address.
124 */
125 typedef struct PP_Var PP_Ext_Socket_NetworkInterface_Dev;
126
127 /**
128 * An array <code>PP_Var</code> which contains elements of
129 * <code>PP_Ext_Socket_NetworkInterface_Dev</code>.
130 */
131 typedef struct PP_Var PP_Ext_Socket_NetworkInterface_Dev_Array;
132 /**
133 * @}
134 */
135
136 /**
137 * @addtogroup Interfaces
138 * @{
139 */
140 struct PPB_Ext_Socket_Dev_0_1 {
141 /**
142 * Creates a socket of the specified type that will connect to the specified
143 * remote machine.
144 *
145 * @param[in] instance A <code>PP_Instance</code>.
146 * @param[in] type A <code>PP_Ext_Socket_SocketType_Dev</code>. The type of
147 * socket to create. Must be <code>tcp</code> or <code>udp</code>.
148 * @param[in] options An undefined <code>PP_Var</code> or
149 * <code>PP_Ext_Socket_CreateOptions_Dev</code>. The socket options.
150 * @param[out] create_info A <code>PP_Ext_Socket_CreateInfo_Dev</code>.
151 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
152 * upon completion.
153 *
154 * @return An error code from <code>pp_errors.h</code>.
155 */
156 int32_t (*Create)(PP_Instance instance,
157 PP_Ext_Socket_SocketType_Dev type,
158 PP_Ext_Socket_CreateOptions_Dev options,
159 PP_Ext_Socket_CreateInfo_Dev* create_info,
160 struct PP_CompletionCallback callback);
161 /**
162 * Destroys the socket. Each socket created should be destroyed after use.
163 *
164 * @param[in] instance A <code>PP_Instance</code>.
165 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
166 */
167 void (*Destroy)(PP_Instance instance, struct PP_Var socket_id);
168 /**
169 * Connects the socket to the remote machine (for a <code>tcp</code> socket).
170 * For a <code>udp</code> socket, this sets the default address which packets
171 * are sent to and read from for <code>Read()</code> and <code>Write()</code>
172 * calls.
173 *
174 * @param[in] instance A <code>PP_Instance</code>.
175 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
176 * @param[in] hostname A string <code>PP_Var</code>. The hostname or IP
177 * address of the remote machine.
178 * @param[in] port An integer <code>PP_Var</code>. The port of the remote
179 * machine.
180 * @param[out] result An integer <code>PP_Var</code>.
181 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
182 * upon completion.
183 *
184 * @return An error code from <code>pp_errors.h</code>.
185 */
186 int32_t (*Connect)(PP_Instance instance,
187 struct PP_Var socket_id,
188 struct PP_Var hostname,
189 struct PP_Var port,
190 struct PP_Var* result,
191 struct PP_CompletionCallback callback);
192 /**
193 * Binds the local address for socket. Currently, it does not support TCP
194 * socket.
195 *
196 * @param[in] instance A <code>PP_Instance</code>.
197 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
198 * @param[in] address A string <code>PP_Var</code>. The address of the local
199 * machine.
200 * @param[in] port An integer <code>PP_Var</code>. The port of the local
201 * machine.
202 * @param[out] result An integer <code>PP_Var</code>.
203 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
204 * upon completion.
205 *
206 * @return An error code from <code>pp_errors.h</code>.
207 */
208 int32_t (*Bind)(PP_Instance instance,
209 struct PP_Var socket_id,
210 struct PP_Var address,
211 struct PP_Var port,
212 struct PP_Var* result,
213 struct PP_CompletionCallback callback);
214 /**
215 * Disconnects the socket. For UDP sockets, <code>Disconnect</code> is a
216 * non-operation but is safe to call.
217 *
218 * @param[in] instance A <code>PP_Instance</code>.
219 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
220 */
221 void (*Disconnect)(PP_Instance instance, struct PP_Var socket_id);
222 /**
223 * Reads data from the given connected socket.
224 *
225 * @param[in] instance A <code>PP_Instance</code>.
226 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
227 * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
228 * read buffer size.
229 * @param[out] read_info A <code>PP_Ext_Socket_ReadInfo_Dev</code>.
230 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
231 * upon completion.
232 *
233 * @return An error code from <code>pp_errors.h</code>.
234 */
235 int32_t (*Read)(PP_Instance instance,
236 struct PP_Var socket_id,
237 struct PP_Var buffer_size,
238 PP_Ext_Socket_ReadInfo_Dev* read_info,
239 struct PP_CompletionCallback callback);
240 /**
241 * Writes data on the given connected socket.
242 *
243 * @param[in] instance A <code>PP_Instance</code>.
244 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
245 * @param[in] data An array buffer <code>PP_Var</code>. The data to write.
246 * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</code>.
247 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
248 * upon completion.
249 *
250 * @return An error code from <code>pp_errors.h</code>.
251 */
252 int32_t (*Write)(PP_Instance instance,
253 struct PP_Var socket_id,
254 struct PP_Var data,
255 PP_Ext_Socket_WriteInfo_Dev* write_info,
256 struct PP_CompletionCallback callback);
257 /**
258 * Receives data from the given UDP socket.
259 *
260 * @param[in] instance A <code>PP_Instance</code>.
261 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
262 * @param[in] buffer_size An undefined or integer <code>PP_Var</code>. The
263 * receive buffer size.
264 * @param[out] recv_from_info A <code>PP_Ext_Socket_RecvFromInfo_Dev</code>.
265 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
266 * upon completion.
267 *
268 * @return An error code from <code>pp_errors.h</code>.
269 */
270 int32_t (*RecvFrom)(PP_Instance instance,
271 struct PP_Var socket_id,
272 struct PP_Var buffer_size,
273 PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info,
274 struct PP_CompletionCallback callback);
275 /**
276 * Sends data on the given UDP socket to the given address and port.
277 *
278 * @param[in] instance A <code>PP_Instance</code>.
279 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
280 * @param[in] data An array buffer <code>PP_Var</code>.
281 * @param[in] address A string <code>PP_Var</code>. The address of the remote
282 * machine.
283 * @param[in] port An integer <code>PP_Var</code>. The port of the remote
284 * machine.
285 * @param[out] write_info A <code>PP_Ext_Socket_WriteInfo_Dev</code>.
286 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
287 * upon completion.
288 *
289 * @return An error code from <code>pp_errors.h</code>.
290 */
291 int32_t (*SendTo)(PP_Instance instance,
292 struct PP_Var socket_id,
293 struct PP_Var data,
294 struct PP_Var address,
295 struct PP_Var port,
296 PP_Ext_Socket_WriteInfo_Dev* write_info,
297 struct PP_CompletionCallback callback);
298 /**
299 * This method applies to TCP sockets only.
300 * Listens for connections on the specified port and address. This effectively
301 * makes this a server socket, and client socket functions (Connect, Read,
302 * Write) can no longer be used on this socket.
303 *
304 * @param[in] instance A <code>PP_Instance</code>.
305 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
306 * @param[in] address A string <code>PP_Var</code>. The address of the local
307 * machine.
308 * @param[in] port An integer <code>PP_Var</code>. The port of the local
309 * machine.
310 * @param[in] backlog An undefined or integer <code>PP_Var</code>. Length of
311 * the socket's listen queue.
312 * @param[out] result An integer <code>PP_Var</code>.
313 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
314 * upon completion.
315 *
316 * @return An error code from <code>pp_errors.h</code>.
317 */
318 int32_t (*Listen)(PP_Instance instance,
319 struct PP_Var socket_id,
320 struct PP_Var address,
321 struct PP_Var port,
322 struct PP_Var backlog,
323 struct PP_Var* result,
324 struct PP_CompletionCallback callback);
325 /**
326 * This method applies to TCP sockets only.
327 * Registers a callback function to be called when a connection is accepted on
328 * this listening server socket. Listen must be called first.
329 * If there is already an active accept callback, this callback will be
330 * invoked immediately with an error as the resultCode.
331 *
332 * @param[in] instance A <code>PP_Instance</code>.
333 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
334 * @param[out] accept_info A <code>PP_Ext_Socket_AcceptInfo_Dev</code>.
335 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
336 * upon completion.
337 *
338 * @return An error code from <code>pp_errors.h</code>.
339 */
340 int32_t (*Accept)(PP_Instance instance,
341 struct PP_Var socket_id,
342 PP_Ext_Socket_AcceptInfo_Dev* accept_info,
343 struct PP_CompletionCallback callback);
344 /**
345 * Enables or disables the keep-alive functionality for a TCP connection.
346 *
347 * @param[in] instance A <code>PP_Instance</code>.
348 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
349 * @param[in] enable A boolean <code>PP_Var</code>. If true, enable keep-alive
350 * functionality.
351 * @param[in] delay An undefined or integer <code>PP_Var</code>. Set the delay
352 * seconds between the last data packet received and the first keepalive
353 * probe. Default is 0.
354 * @param[out] result A boolean <code>PP_Var</code>.
355 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
356 * upon completion.
357 *
358 * @return An error code from <code>pp_errors.h</code>.
359 */
360 int32_t (*SetKeepAlive)(PP_Instance instance,
361 struct PP_Var socket_id,
362 struct PP_Var enable,
363 struct PP_Var delay,
364 struct PP_Var* result,
365 struct PP_CompletionCallback callback);
366 /**
367 * Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
368 * algorithm will be disabled when <code>TCP_NODELAY</code> is set.
369 *
370 * @param[in] instance A <code>PP_Instance</code>.
371 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
372 * @param[in] no_delay A boolean <code>PP_Var</code>.
373 * @param[out] result A boolean <code>PP_Var</code>.
374 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
375 * upon completion.
376 *
377 * @return An error code from <code>pp_errors.h</code>.
378 */
379 int32_t (*SetNoDelay)(PP_Instance instance,
380 struct PP_Var socket_id,
381 struct PP_Var no_delay,
382 struct PP_Var* result,
383 struct PP_CompletionCallback callback);
384 /**
385 * Retrieves the state of the given socket.
386 *
387 * @param[in] instance A <code>PP_Instance</code>.
388 * @param[in] socket_id An integer <code>PP_Var</code>. The socket ID.
389 * @param[out] result A <code>PP_Ext_Socket_SocketInfo_Dev</code>.
390 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
391 * upon completion.
392 *
393 * @return An error code from <code>pp_errors.h</code>.
394 */
395 int32_t (*GetInfo)(PP_Instance instance,
396 struct PP_Var socket_id,
397 PP_Ext_Socket_SocketInfo_Dev* result,
398 struct PP_CompletionCallback callback);
399 /**
400 * Retrieves information about local adapters on this system.
401 *
402 * @param[in] instance A <code>PP_Instance</code>.
403 * @param[out] result A <code>PP_Ext_Socket_NetworkInterface_Dev_Array</code>.
404 * @param[in] callback A <code>PP_CompletionCallback</code> to be called
405 * upon completion.
406 *
407 * @return An error code from <code>pp_errors.h</code>.
408 */
409 int32_t (*GetNetworkList)(PP_Instance instance,
410 PP_Ext_Socket_NetworkInterface_Dev_Array* result,
411 struct PP_CompletionCallback callback);
412 };
413
414 typedef struct PPB_Ext_Socket_Dev_0_1 PPB_Ext_Socket_Dev;
415 /**
416 * @}
417 */
418
419 #endif /* PPAPI_C_EXTENSIONS_DEV_PPB_EXT_SOCKET_DEV_H_ */
420
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698