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

Side by Side Diff: ppapi/api/ppb_tcp_socket.idl

Issue 24195004: PPB_TCPSocket: add support for TCP server socket operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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_TCPSocket</code> interface. 7 * This file defines the <code>PPB_TCPSocket</code> interface.
8 */ 8 */
9 9
10 [generate_thunk]
11
12 label Chrome { 10 label Chrome {
13 M29 = 1.0 11 M29 = 1.0,
12 M31 = 1.1
14 }; 13 };
15 14
16 /** 15 /**
17 * Option names used by <code>SetOption()</code>. 16 * Option names used by <code>SetOption()</code>.
18 */ 17 */
19 [assert_size(4)] 18 [assert_size(4)]
20 enum PP_TCPSocket_Option { 19 enum PP_TCPSocket_Option {
21 /** 20 /**
22 * Disables coalescing of small writes to make TCP segments, and instead 21 * Disables coalescing of small writes to make TCP segments, and instead
23 * delivers data immediately. Value's type is <code>PP_VARTYPE_BOOL</code>. 22 * delivers data immediately. Value's type is <code>PP_VARTYPE_BOOL</code>.
(...skipping 14 matching lines...) Expand all
38 37
39 /** 38 /**
40 * Specifies the total per-socket buffer space reserved for receives. Value's 39 * Specifies the total per-socket buffer space reserved for receives. Value's
41 * type should be <code>PP_VARTYPE_INT32</code>. 40 * type should be <code>PP_VARTYPE_INT32</code>.
42 * This option can only be set after a successful <code>Connect()</code> call. 41 * This option can only be set after a successful <code>Connect()</code> call.
43 * 42 *
44 * Note: This is only treated as a hint for the browser to set the buffer 43 * Note: This is only treated as a hint for the browser to set the buffer
45 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't 44 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't
46 * guarantee it will conform to the size. 45 * guarantee it will conform to the size.
47 */ 46 */
48 PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE = 2 47 PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE = 2,
48
49 /**
50 * Allows the socket to share the local address to which it will be bound.
51 * Value's type should be <code>PP_VARTYPE_BOOL</code>.
52 * This option can only be set before calling <code>Bind()</code>.
53 * Supported since version 1.1.
54 */
55 PP_TCPSOCKET_OPTION_ADDRESS_REUSE = 3
bbudge 2013/09/19 22:30:58 could we use the [version=1.1] annotation here? I
yzshen1 2013/09/19 23:14:42 I tried but the generation result was wrong. It wi
49 }; 56 };
50 57
51 /** 58 /**
52 * The <code>PPB_TCPSocket</code> interface provides TCP socket operations. 59 * The <code>PPB_TCPSocket</code> interface provides TCP socket operations.
53 * 60 *
54 * Permissions: Apps permission <code>socket</code> with subrule 61 * Permissions: Apps permission <code>socket</code> with subrule
55 * <code>tcp-connect</code> is required for <code>Connect()</code>. 62 * <code>tcp-connect</code> is required for <code>Connect()</code>; subrule
63 * <code>tcp-listen</code> is required for <code>Listen()</code>.
56 * For more details about network communication permissions, please see: 64 * For more details about network communication permissions, please see:
57 * http://developer.chrome.com/apps/app_network.html 65 * http://developer.chrome.com/apps/app_network.html
58 */ 66 */
59 interface PPB_TCPSocket { 67 interface PPB_TCPSocket {
60 /** 68 /**
61 * Creates a TCP socket resource. 69 * Creates a TCP socket resource.
62 * 70 *
63 * @param[in] instance A <code>PP_Instance</code> identifying one instance of 71 * @param[in] instance A <code>PP_Instance</code> identifying one instance of
64 * a module. 72 * a module.
65 * 73 *
66 * @return A <code>PP_Resource</code> corresponding to a TCP socket or 0 74 * @return A <code>PP_Resource</code> corresponding to a TCP socket or 0
67 * on failure. 75 * on failure.
68 */ 76 */
69 PP_Resource Create([in] PP_Instance instance); 77 PP_Resource Create([in] PP_Instance instance);
70 78
71 /** 79 /**
72 * Determines if a given resource is a TCP socket. 80 * Determines if a given resource is a TCP socket.
73 * 81 *
74 * @param[in] resource A <code>PP_Resource</code> to check. 82 * @param[in] resource A <code>PP_Resource</code> to check.
75 * 83 *
76 * @return <code>PP_TRUE</code> if the input is a 84 * @return <code>PP_TRUE</code> if the input is a
77 * <code>PPB_TCPSocket</code> resource; <code>PP_FALSE</code> otherwise. 85 * <code>PPB_TCPSocket</code> resource; <code>PP_FALSE</code> otherwise.
78 */ 86 */
79 PP_Bool IsTCPSocket([in] PP_Resource resource); 87 PP_Bool IsTCPSocket([in] PP_Resource resource);
80 88
81 /** 89 /**
82 * Connects the socket to the given address. 90 * Binds the socket to the given address. The socket must not be bound.
83 * 91 *
84 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP 92 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
85 * socket. 93 * socket.
94 * @param[in] addr A <code>PPB_NetAddress</code> resource.
95 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
96 * completion.
97 *
98 * @return An int32_t containing an error code from <code>pp_errors.h</code>,
99 * including (but not limited to):
100 * - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use.
101 * - <code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid.
102 */
103 [version=1.1]
104 int32_t Bind([in] PP_Resource tcp_socket,
105 [in] PP_Resource addr,
106 [in] PP_CompletionCallback callback);
107
108 /**
109 * Connects the socket to the given address. The socket must not be listening.
110 * Binding the socket beforehand is optional.
111 *
112 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
113 * socket.
86 * @param[in] addr A <code>PPB_NetAddress</code> resource. 114 * @param[in] addr A <code>PPB_NetAddress</code> resource.
87 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 115 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
88 * completion. 116 * completion.
89 * 117 *
90 * @return An int32_t containing an error code from <code>pp_errors.h</code>, 118 * @return An int32_t containing an error code from <code>pp_errors.h</code>,
91 * including (but not limited to): 119 * including (but not limited to):
92 * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required 120 * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required
93 * permissions. 121 * permissions.
94 * - <code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is 122 * - <code>PP_ERROR_ADDRESS_UNREACHABLE</code>: <code>addr</code> is
95 * unreachable. 123 * unreachable.
96 * - <code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was 124 * - <code>PP_ERROR_CONNECTION_REFUSED</code>: the connection attempt was
97 * refused. 125 * refused.
98 * - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. 126 * - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed.
99 * - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed 127 * - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed
100 * out. 128 * out.
129 *
130 * If the socket is listening/connected or has a pending listen/connect
131 * request, <code>Connect()</code> will fail without starting a connection
132 * attempt. Otherwise, any failure during the connection attempt will cause
133 * the socket to be closed.
101 */ 134 */
102 int32_t Connect([in] PP_Resource tcp_socket, 135 int32_t Connect([in] PP_Resource tcp_socket,
103 [in] PP_Resource addr, 136 [in] PP_Resource addr,
104 [in] PP_CompletionCallback callback); 137 [in] PP_CompletionCallback callback);
105 138
106 /** 139 /**
107 * Gets the local address of the socket, if it is connected. 140 * Gets the local address of the socket, if it is bound.
108 * 141 *
109 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP 142 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
110 * socket. 143 * socket.
111 * 144 *
112 * @return A <code>PPB_NetAddress</code> resource on success or 0 on failure. 145 * @return A <code>PPB_NetAddress</code> resource on success or 0 on failure.
113 */ 146 */
114 PP_Resource GetLocalAddress([in] PP_Resource tcp_socket); 147 PP_Resource GetLocalAddress([in] PP_Resource tcp_socket);
115 148
116 /** 149 /**
117 * Gets the remote address of the socket, if it is connected. 150 * Gets the remote address of the socket, if it is connected.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 188 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
156 * completion. 189 * completion.
157 * 190 *
158 * @return A non-negative number on success to indicate how many bytes have 191 * @return A non-negative number on success to indicate how many bytes have
159 * been written; otherwise, an error code from <code>pp_errors.h</code>. 192 * been written; otherwise, an error code from <code>pp_errors.h</code>.
160 */ 193 */
161 int32_t Write([in] PP_Resource tcp_socket, 194 int32_t Write([in] PP_Resource tcp_socket,
162 [in] str_t buffer, 195 [in] str_t buffer,
163 [in] int32_t bytes_to_write, 196 [in] int32_t bytes_to_write,
164 [in] PP_CompletionCallback callback); 197 [in] PP_CompletionCallback callback);
198 /**
199 * Starts listening. The socket must be bound and not connected.
200 *
201 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
202 * socket.
203 * @param[in] backlog A hint to determine the maximum length to which the
204 * queue of pending connections may grow.
205 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
206 * completion.
207 *
208 * @return An int32_t containing an error code from <code>pp_errors.h</code>,
209 * including (but not limited to):
210 * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required
211 * permissions.
212 * - <code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already listening
213 * on the same port.
214 */
215 [version=1.1]
216 int32_t Listen([in] PP_Resource tcp_socket,
217 [in] int32_t backlog,
218 [in] PP_CompletionCallback callback);
165 219
166 /** 220 /**
167 * Cancels all pending reads and writes and disconnects the socket. Any 221 * Accepts a connection. The socket must be listening.
168 * pending callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> 222 *
169 * if pending IO was interrupted. After a call to this method, no output 223 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
170 * buffer pointers passed into previous <code>Read()</code> calls will be 224 * socket.
171 * accessed. It is not valid to call <code>Connect()</code> again. 225 * @param[out] accepted_tcp_socket Stores the accepted TCP socket on success.
226 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
227 * completion.
228 *
229 * @return An int32_t containing an error code from <code>pp_errors.h</code>,
230 * including (but not limited to):
231 * - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted.
232 */
233 [version=1.1]
234 int32_t Accept([in] PP_Resource tcp_socket,
235 [out] PP_Resource accepted_tcp_socket,
236 [in] PP_CompletionCallback callback);
237
238 /**
239 * Cancels all pending operations and closes the socket. Any pending callbacks
240 * will still run, reporting <code>PP_ERROR_ABORTED</code> if pending IO was
241 * interrupted. After a call to this method, no output buffer pointers passed
242 * into previous <code>Read()</code> or <code>Accept()</code> calls will be
243 * accessed. It is not valid to call <code>Connect()</code> or
244 * <code>Listen()</code> again.
172 * 245 *
173 * The socket is implicitly closed if it is destroyed, so you are not required 246 * The socket is implicitly closed if it is destroyed, so you are not required
174 * to call this method. 247 * to call this method.
175 * 248 *
176 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP 249 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
177 * socket. 250 * socket.
178 */ 251 */
179 void Close([in] PP_Resource tcp_socket); 252 void Close([in] PP_Resource tcp_socket);
180 253
181 /** 254 /**
182 * Sets a socket option on the TCP socket. 255 * Sets a socket option on the TCP socket.
183 * Please see the <code>PP_TCPSocket_Option</code> description for option 256 * Please see the <code>PP_TCPSocket_Option</code> description for option
184 * names, value types and allowed values. 257 * names, value types and allowed values.
185 * 258 *
186 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP 259 * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP
187 * socket. 260 * socket.
188 * @param[in] name The option to set. 261 * @param[in] name The option to set.
189 * @param[in] value The option value to set. 262 * @param[in] value The option value to set.
190 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 263 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
191 * completion. 264 * completion.
192 * 265 *
193 * @return An int32_t containing an error code from <code>pp_errors.h</code>. 266 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
194 */ 267 */
195 int32_t SetOption([in] PP_Resource tcp_socket, 268 int32_t SetOption([in] PP_Resource tcp_socket,
196 [in] PP_TCPSocket_Option name, 269 [in] PP_TCPSocket_Option name,
197 [in] PP_Var value, 270 [in] PP_Var value,
198 [in] PP_CompletionCallback callback); 271 [in] PP_CompletionCallback callback);
199 }; 272 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698