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

Side by Side Diff: ppapi/c/dev/ppb_udp_socket_dev.h

Issue 16938011: Update comments of the Pepper networking APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « ppapi/c/dev/ppb_tcp_socket_dev.h ('k') | ppapi/cpp/dev/host_resolver_dev.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright 2013 The Chromium Authors. All rights reserved. 1 /* Copyright 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* From dev/ppb_udp_socket_dev.idl modified Tue Jun 18 22:26:29 2013. */ 6 /* From dev/ppb_udp_socket_dev.idl modified Thu Jun 20 15:15:36 2013. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ 8 #ifndef PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_
9 #define PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ 9 #define PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_
10 10
11 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h" 14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
17 #include "ppapi/c/pp_var.h" 17 #include "ppapi/c/pp_var.h"
18 18
19 #define PPB_UDPSOCKET_DEV_INTERFACE_0_1 "PPB_UDPSocket(Dev);0.1" 19 #define PPB_UDPSOCKET_DEV_INTERFACE_0_1 "PPB_UDPSocket(Dev);0.1"
20 #define PPB_UDPSOCKET_DEV_INTERFACE PPB_UDPSOCKET_DEV_INTERFACE_0_1 20 #define PPB_UDPSOCKET_DEV_INTERFACE PPB_UDPSOCKET_DEV_INTERFACE_0_1
21 21
22 /** 22 /**
23 * @file 23 * @file
24 * This file defines the <code>PPB_UDPSocket_Dev</code> interface. 24 * This file defines the <code>PPB_UDPSocket_Dev</code> interface.
25 * TODO(yzshen): Tidy up the document.
26 */ 25 */
27 26
28 27
29 /** 28 /**
30 * @addtogroup Enums 29 * @addtogroup Enums
31 * @{ 30 * @{
32 */ 31 */
32 /**
33 * Option names used by <code>SetOption()</code>.
34 */
33 typedef enum { 35 typedef enum {
34 /* Allows the socket to share the local address to which it will be bound with 36 /**
35 * other processes. Value's type should be PP_VARTYPE_BOOL. 37 * Allows the socket to share the local address to which it will be bound with
36 * This option can only be set before calling Bind(). */ 38 * other processes. Value's type should be <code>PP_VARTYPE_BOOL</code>.
39 * This option can only be set before calling <code>Bind()</code>.
40 */
37 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, 41 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0,
38 /* Allows sending and receiving packets to and from broadcast addresses. 42 /**
39 * Value's type should be PP_VARTYPE_BOOL. 43 * Allows sending and receiving packets to and from broadcast addresses.
40 * This option can only be set before calling Bind(). */ 44 * Value's type should be <code>PP_VARTYPE_BOOL</code>.
45 * This option can only be set before calling <code>Bind()</code>.
46 */
41 PP_UDPSOCKET_OPTION_BROADCAST = 1, 47 PP_UDPSOCKET_OPTION_BROADCAST = 1,
42 /* Specifies the total per-socket buffer space reserved for sends. Value's 48 /**
43 * type should be PP_VARTYPE_INT32. 49 * Specifies the total per-socket buffer space reserved for sends. Value's
44 * This option can only be set after a successful Bind() call. 50 * type should be <code>PP_VARTYPE_INT32</code>.
51 * This option can only be set after a successful <code>Bind()</code> call.
52 *
45 * Note: This is only treated as a hint for the browser to set the buffer 53 * Note: This is only treated as a hint for the browser to set the buffer
46 * size. Even if SetOption() reports that this option has been successfully 54 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't
47 * set, the browser doesn't guarantee it will conform to it. */ 55 * guarantee it will conform to the size.
56 */
48 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, 57 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2,
49 /* Specifies the total per-socket buffer space reserved for receives. Value's 58 /**
50 * type should be PP_VARTYPE_INT32. 59 * Specifies the total per-socket buffer space reserved for receives. Value's
51 * This option can only be set after a successful Bind() call. 60 * type should be <code>PP_VARTYPE_INT32</code>.
61 * This option can only be set after a successful <code>Bind()</code> call.
62 *
52 * Note: This is only treated as a hint for the browser to set the buffer 63 * Note: This is only treated as a hint for the browser to set the buffer
53 * size. Even if SetOption() reports that this option has been successfully 64 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't
54 * set, the browser doesn't guarantee it will conform to it. */ 65 * guarantee it will conform to the size.
66 */
55 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 67 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3
56 } PP_UDPSocket_Option_Dev; 68 } PP_UDPSocket_Option_Dev;
57 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option_Dev, 4); 69 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option_Dev, 4);
58 /** 70 /**
59 * @} 71 * @}
60 */ 72 */
61 73
62 /** 74 /**
63 * @addtogroup Interfaces 75 * @addtogroup Interfaces
64 * @{ 76 * @{
65 */ 77 */
78 /**
79 * The <code>PPB_UDPSocket_Dev</code> interface provides UDP socket operations.
80 *
81 * Permissions: Apps permission <code>socket</code> with subrule
82 * <code>udp-bind</code> is required for <code>Bind()</code>; subrule
83 * <code>udp-send-to</code> is required for <code>SendTo()</code>.
84 * For more details about network communication permissions, please see:
85 * http://developer.chrome.com/apps/app_network.html
86 */
66 struct PPB_UDPSocket_Dev_0_1 { 87 struct PPB_UDPSocket_Dev_0_1 {
67 /** 88 /**
68 * Creates a UDP socket resource. 89 * Creates a UDP socket resource.
90 *
91 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
92 * a module.
93 *
94 * @return A <code>PP_Resource</code> corresponding to a UDP socket or 0
95 * on failure.
69 */ 96 */
70 PP_Resource (*Create)(PP_Instance instance); 97 PP_Resource (*Create)(PP_Instance instance);
71 /** 98 /**
72 * Determines if a given resource is a UDP socket. 99 * Determines if a given resource is a UDP socket.
100 *
101 * @param[in] resource A <code>PP_Resource</code> to check.
102 *
103 * @return <code>PP_TRUE</code> if the input is a
104 * <code>PPB_UDPSocket_Dev</code> resource; <code>PP_FALSE</code>
105 * otherwise.
73 */ 106 */
74 PP_Bool (*IsUDPSocket)(PP_Resource resource); 107 PP_Bool (*IsUDPSocket)(PP_Resource resource);
75 /** 108 /**
76 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev 109 * Binds the socket to the given address.
77 * resource. 110 *
111 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
112 * socket.
113 * @param[in] addr A <code>PPB_NetAddress_Dev</code> resource.
114 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
115 * completion.
116 *
117 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
118 * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
119 * required permissions. <code>PP_ERROR_ADDRESS_IN_USE</code> will be returned
120 * if the address is already in use.
78 */ 121 */
79 int32_t (*Bind)(PP_Resource udp_socket, 122 int32_t (*Bind)(PP_Resource udp_socket,
80 PP_Resource addr, 123 PP_Resource addr,
81 struct PP_CompletionCallback callback); 124 struct PP_CompletionCallback callback);
82 /** 125 /**
83 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev 126 * Gets the address that the socket is bound to. The socket must be bound.
84 * resource. Bind must be called and succeed first. Returns 0 if Bind fails, 127 *
85 * or if Close has been called. 128 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
129 * socket.
130 *
131 * @return A <code>PPB_NetAddress_Dev</code> resource on success or 0 on
132 * failure.
86 */ 133 */
87 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); 134 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket);
88 /** 135 /**
89 * Performs a non-blocking recvfrom call on socket. 136 * Receives data from the socket and stores the source address. The socket
90 * Bind must be called first. |callback| is invoked when recvfrom reads data. 137 * must be bound.
91 * |addr| will store a PPB_NetAddress_Dev resource on success. 138 *
139 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
140 * socket.
141 * @param[out] buffer The buffer to store the received data on success. It
142 * must be at least as large as <code>num_bytes</code>.
143 * @param[in] num_bytes The number of bytes to receive.
144 * @param[out] addr A <code>PPB_NetAddress_Dev</code> resource to store the
145 * source address on success.
146 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
147 * completion.
148 *
149 * @return A non-negative number on success to indicate how many bytes have
150 * been received; otherwise, an error code from <code>pp_errors.h</code>.
92 */ 151 */
93 int32_t (*RecvFrom)(PP_Resource udp_socket, 152 int32_t (*RecvFrom)(PP_Resource udp_socket,
94 char* buffer, 153 char* buffer,
95 int32_t num_bytes, 154 int32_t num_bytes,
96 PP_Resource* addr, 155 PP_Resource* addr,
97 struct PP_CompletionCallback callback); 156 struct PP_CompletionCallback callback);
98 /** 157 /**
99 * Performs a non-blocking sendto call on the socket. 158 * Sends data to a specific destination. The socket must be bound.
100 * Bind must be called first. |addr| is a PPB_NetAddress_Dev resource holding 159 *
101 * the target address. |callback| is invoked when sendto completes. 160 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
161 * socket.
162 * @param[in] buffer The buffer containing the data to send.
163 * @param[in] num_bytes The number of bytes to send.
164 * @param[in] addr A <code>PPB_NetAddress_Dev</code> resource holding the
165 * destination address.
166 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
167 * completion.
168 *
169 * @return A non-negative number on success to indicate how many bytes have
170 * been sent; otherwise, an error code from <code>pp_errors.h</code>.
171 * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have
172 * required permissions.
102 */ 173 */
103 int32_t (*SendTo)(PP_Resource udp_socket, 174 int32_t (*SendTo)(PP_Resource udp_socket,
104 const char* buffer, 175 const char* buffer,
105 int32_t num_bytes, 176 int32_t num_bytes,
106 PP_Resource addr, 177 PP_Resource addr,
107 struct PP_CompletionCallback callback); 178 struct PP_CompletionCallback callback);
108 /** 179 /**
109 * Cancels all pending reads and writes, and closes the socket. 180 * Cancels all pending reads and writes, and closes the socket. Any pending
181 * callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> if
182 * pending IO was interrupted. After a call to this method, no output
183 * parameters passed into previous <code>RecvFrom()</code> calls will be
184 * accessed. It is not valid to call <code>Bind()</code> again.
185 *
186 * The socket is implicitly closed if it is destroyed, so you are not
187 * required to call this method.
188 *
189 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
190 * socket.
110 */ 191 */
111 void (*Close)(PP_Resource udp_socket); 192 void (*Close)(PP_Resource udp_socket);
112 /** 193 /**
113 * Sets a socket option on |udp_socket|. 194 * Sets a socket option on the UDP socket.
114 * See the PP_UDPSocket_Option_Dev description for option names, value types 195 * Please see the <code>PP_UDPSocket_Option_Dev</code> description for option
115 * and allowed values. 196 * names, value types and allowed values.
116 * Returns PP_OK on success. Otherwise, returns PP_ERROR_BADRESOURCE (if bad 197 *
117 * |udp_socket| provided), PP_ERROR_BADARGUMENT (if bad name/value/value's 198 * @param[in] udp_socket A <code>PP_Resource</code> corresponding to a UDP
118 * type provided) or PP_ERROR_FAILED in the case of internal errors. 199 * socket.
200 * @param[in] name The option to set.
201 * @param[in] value The option value to set.
202 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
203 * completion.
204 *
205 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
119 */ 206 */
120 int32_t (*SetOption)(PP_Resource udp_socket, 207 int32_t (*SetOption)(PP_Resource udp_socket,
121 PP_UDPSocket_Option_Dev name, 208 PP_UDPSocket_Option_Dev name,
122 struct PP_Var value, 209 struct PP_Var value,
123 struct PP_CompletionCallback callback); 210 struct PP_CompletionCallback callback);
124 }; 211 };
125 212
126 typedef struct PPB_UDPSocket_Dev_0_1 PPB_UDPSocket_Dev; 213 typedef struct PPB_UDPSocket_Dev_0_1 PPB_UDPSocket_Dev;
127 /** 214 /**
128 * @} 215 * @}
129 */ 216 */
130 217
131 #endif /* PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ */ 218 #endif /* PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ */
132 219
OLDNEW
« no previous file with comments | « ppapi/c/dev/ppb_tcp_socket_dev.h ('k') | ppapi/cpp/dev/host_resolver_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698