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

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
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
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 */
21 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, 26 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0,
22 27
23 // Allows sending and receiving packets to and from broadcast addresses. 28 /**
24 // Value's type should be PP_VARTYPE_BOOL. 29 * Allows sending and receiving packets to and from broadcast addresses.
30 * Value's type should be <code>PP_VARTYPE_BOOL</code>.
31 * This option can only be set before calling <code>Bind()</code>.
32 */
25 PP_UDPSOCKET_OPTION_BROADCAST = 1, 33 PP_UDPSOCKET_OPTION_BROADCAST = 1,
26 34
27 // Specifies the total per-socket buffer space reserved for sends. Value's 35 /**
28 // type should be PP_VARTYPE_INT32. 36 * Specifies the total per-socket buffer space reserved for sends. Value's
29 // Note: This is only treated as a hint for the browser to set the buffer 37 * type should be <code>PP_VARTYPE_INT32</code>.
30 // size. Even if SetOption() reports that this option has been successfully 38 * This option can only be set after a successful <code>Bind()</code> call.
31 // set, the browser doesn't guarantee it will conform to it. 39 *
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 */
32 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, 44 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2,
33 45
34 // Specifies the total per-socket buffer space reserved for receives. Value's 46 /**
35 // type should be PP_VARTYPE_INT32. 47 * Specifies the total per-socket buffer space reserved for receives. Value's
36 // Note: This is only treated as a hint for the browser to set the buffer 48 * type should be <code>PP_VARTYPE_INT32</code>.
37 // size. Even if SetOption() reports that this option has been successfully 49 * This option can only be set after a successful <code>Bind()</code> call.
38 // set, the browser doesn't guarantee it will conform to it. 50 *
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 */
39 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 55 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3
40 }; 56 };
41 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 */
42 interface PPB_UDPSocket_Dev { 67 interface PPB_UDPSocket_Dev {
43 /** 68 /**
44 * 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.
45 */ 76 */
46 PP_Resource Create([in] PP_Instance instance); 77 PP_Resource Create([in] PP_Instance instance);
47 78
48 /** 79 /**
49 * 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.
50 */ 87 */
51 PP_Bool IsUDPSocket([in] PP_Resource resource); 88 PP_Bool IsUDPSocket([in] PP_Resource resource);
52 89
53 /** 90 /**
54 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev 91 * Binds the socket to the given address.
55 * 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.
56 */ 103 */
57 int32_t Bind([in] PP_Resource udp_socket, 104 int32_t Bind([in] PP_Resource udp_socket,
58 [in] PP_Resource addr, 105 [in] PP_Resource addr,
59 [in] PP_CompletionCallback callback); 106 [in] PP_CompletionCallback callback);
60 107
61 /** 108 /**
62 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev 109 * Gets the address that the socket has bound to. The socket must be bound.
63 * resource. Bind must be called and succeed first. Returns 0 if Bind fails, 110 *
64 * 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.
65 */ 116 */
66 PP_Resource GetBoundAddress([in] PP_Resource udp_socket); 117 PP_Resource GetBoundAddress([in] PP_Resource udp_socket);
67 118
68 /** 119 /**
69 * Performs a non-blocking recvfrom call on socket. 120 * Receives data from the socket and stores the source address. The socket
70 * Bind must be called first. |callback| is invoked when recvfrom reads data. 121 * must be bound.
71 * |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>.
72 */ 135 */
73 int32_t RecvFrom([in] PP_Resource udp_socket, 136 int32_t RecvFrom([in] PP_Resource udp_socket,
74 [out] str_t buffer, 137 [out] str_t buffer,
75 [in] int32_t num_bytes, 138 [in] int32_t num_bytes,
76 [out] PP_Resource addr, 139 [out] PP_Resource addr,
77 [in] PP_CompletionCallback callback); 140 [in] PP_CompletionCallback callback);
78 141
79 /** 142 /**
80 * Performs a non-blocking sendto call on the socket. 143 * Sends data to a specific destination. The socket must be bound.
81 * Bind must be called first. |addr| is a PPB_NetAddress_Dev resource holding 144 *
82 * 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.
83 */ 158 */
84 int32_t SendTo([in] PP_Resource udp_socket, 159 int32_t SendTo([in] PP_Resource udp_socket,
85 [in] str_t buffer, 160 [in] str_t buffer,
86 [in] int32_t num_bytes, 161 [in] int32_t num_bytes,
87 [in] PP_Resource addr, 162 [in] PP_Resource addr,
88 [in] PP_CompletionCallback callback); 163 [in] PP_CompletionCallback callback);
89 164
90 /** 165 /**
91 * 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, not output
bbudge 2013/06/20 21:02:32 s/not/no
yzshen1 2013/06/20 22:20:48 Done.
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.
92 */ 177 */
93 void Close([in] PP_Resource udp_socket); 178 void Close([in] PP_Resource udp_socket);
94 179
95 /** 180 /**
96 * Sets a socket option to |udp_socket|. Should be called before Bind(). 181 * Sets a socket option on the UDP socket.
97 * 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
98 * and allowed values. 183 * names, value types and allowed values.
99 * Returns PP_OK on success. Otherwise, returns PP_ERROR_BADRESOURCE (if bad 184 *
100 * |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
101 * type provided) or PP_ERROR_FAILED in the case of internal errors. 186 * socket.
187 * @param[in] name The option type 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>.
102 */ 193 */
103 int32_t SetOption([in] PP_Resource udp_socket, 194 int32_t SetOption([in] PP_Resource udp_socket,
104 [in] PP_UDPSocket_Option_Dev name, 195 [in] PP_UDPSocket_Option_Dev name,
105 [in] PP_Var value, 196 [in] PP_Var value,
106 [in] PP_CompletionCallback callback); 197 [in] PP_CompletionCallback callback);
107 }; 198 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698