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

Side by Side Diff: ppapi/api/dev/ppb_udp_socket_dev.idl

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

Powered by Google App Engine
This is Rietveld 408576698