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

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

Issue 8821010: WebSocket Pepper API: C++ bindings implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: straightforward C++ interface Created 9 years 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 (c) 2011 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2011 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_websocket_dev.idl modified Wed Nov 16 02:46:08 2011. */ 6 /* From dev/ppb_websocket_dev.idl modified Fri Dec 9 16:54:10 2011. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ 8 #ifndef PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_
9 #define PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ 9 #define PPAPI_C_DEV_PPB_WEBSOCKET_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"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 * 114 *
115 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 115 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
116 * WebSocket. 116 * WebSocket.
117 * 117 *
118 * @param[in] url A <code>PP_Var</code> representing a WebSocket server URL. 118 * @param[in] url A <code>PP_Var</code> representing a WebSocket server URL.
119 * The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>. 119 * The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>.
120 * 120 *
121 * @param[in] protocols A pointer to an array of <code>PP_Var</code> 121 * @param[in] protocols A pointer to an array of <code>PP_Var</code>
122 * specifying sub-protocols. Each <code>PP_Var</code> represents one 122 * specifying sub-protocols. Each <code>PP_Var</code> represents one
123 * sub-protocol and its <code>PP_VarType</code> must be 123 * sub-protocol and its <code>PP_VarType</code> must be
124 * <code>PP_VARTYPE_STRING</code>. This argument can be null only if 124 * <code>PP_VARTYPE_STRING</code>.
125 * <code>protocol_count</code> is 0.
126 * 125 *
127 * @param[in] protocol_count The number of sub-protocols in 126 * @param[in] protocol_count The number of sub-protocols in
128 * <code>protocols</code>. 127 * <code>protocols</code>.
129 * 128 *
130 * @param[in] callback A <code>PP_CompletionCallback</code> which is called 129 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
131 * when the connection is established or an error occurs in establishing 130 * when the connection is established or an error occurs in establishing
132 * connection. 131 * connection.
133 * 132 *
134 * @return In case of immediate failure, returns an error code as follows. 133 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is
135 * Returns <code>PP_ERROR_BADARGUMENT</code> corresponding to JavaScript 134 * invoked with one of following results.
136 * SyntaxError and <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript 135 * <code>PP_ERROR_BADARGUMENT</code> corresponds to JavaScript SyntaxError,
137 * SecurityError. Otherwise, returns <code>PP_OK_COMPLETIONPENDING</code> 136 * <code>PP_ERROR_NOACCESS</code> corresponds to JavaScript SecurityError,
138 * and invokes <code>callback</code> later. 137 * and returns <code>PP_ERROR_INPROGRESS</code> if the call is not the first
138 * time.
139 */ 139 */
140 int32_t (*Connect)(PP_Resource web_socket, 140 int32_t (*Connect)(PP_Resource web_socket,
141 struct PP_Var url, 141 struct PP_Var url,
142 const struct PP_Var protocols[], 142 const struct PP_Var protocols[],
143 uint32_t protocol_count, 143 uint32_t protocol_count,
144 struct PP_CompletionCallback callback); 144 struct PP_CompletionCallback callback);
145 /** 145 /**
146 * Close() closes the specified WebSocket connection by specifying 146 * Close() closes the specified WebSocket connection by specifying
147 * <code>code</code> and <code>reason</code>. 147 * <code>code</code> and <code>reason</code>.
148 * 148 *
149 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 149 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
150 * WebSocket. 150 * WebSocket.
151 * 151 *
152 * @param[in] code The WebSocket close code. Ignored if it is 0. 152 * @param[in] code The WebSocket close code. Ignored if it is 0.
153 * 153 *
154 * @param[in] reason A <code>PP_Var</code> which represents the WebSocket 154 * @param[in] reason A <code>PP_Var</code> which represents the WebSocket
155 * close reason. Ignored if it is <code>PP_VARTYPE_UNDEFINED</code>. 155 * close reason. Ignored if it is <code>PP_VARTYPE_UNDEFINED</code>.
156 * Otherwise, its <code>PP_VarType</code> must be 156 * Otherwise, its <code>PP_VarType</code> must be
157 * <code>PP_VARTYPE_STRING</code>. 157 * <code>PP_VARTYPE_STRING</code>.
158 * 158 *
159 * @param[in] callback A <code>PP_CompletionCallback</code> which is called 159 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
160 * when the connection is closed or an error occurs in closing connection. 160 * when the connection is closed or an error occurs in closing connection.
161 * 161 *
162 * @return In case of immediate failure, returns an error code as follows. 162 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is
163 * Returns <code>PP_ERROR_BADARGUMENT</code> corresponding to JavaScript 163 * invoked with one of following results.
164 * SyntaxError and <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript 164 * <code>PP_ERROR_BADARGUMENT</code> corresponds to JavaScript SyntaxError,
165 * InvalidAccessError. Otherwise, returns 165 * <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript
166 * <code>PP_OK_COMPLETIONPENDING</code> and invokes <code>callback</code> 166 * InvalidAccessError. Returns <code>PP_ERROR_INPROGRESS</code> if the call
167 * later. 167 * is not the first time.
168 */ 168 */
169 int32_t (*Close)(PP_Resource web_socket, 169 int32_t (*Close)(PP_Resource web_socket,
170 uint16_t code, 170 uint16_t code,
171 struct PP_Var reason, 171 struct PP_Var reason,
172 struct PP_CompletionCallback callback); 172 struct PP_CompletionCallback callback);
173 /** 173 /**
174 * ReceiveMessage() receives a message from the WebSocket server. 174 * ReceiveMessage() receives a message from the WebSocket server.
175 * This interface only returns bytes of a single message. That is, this 175 * This interface only returns bytes of a single message. That is, this
176 * interface must be called at least N times to receive N messages, no matter 176 * interface must be called at least N times to receive N messages, no matter
177 * how small each message is. 177 * how small each message is.
178 * 178 *
179 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 179 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
180 * WebSocket. 180 * WebSocket.
181 * 181 *
182 * @param[out] message The received message is copied to provided 182 * @param[out] message The received message is copied to provided
183 * <code>message</code>. 183 * <code>message</code>.
184 * 184 *
185 * @param[in] callback A <code>PP_CompletionCallback</code> which is called 185 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
186 * when the receiving message is completed. It is ignored when the function 186 * when the receiving message is completed. It is ignored when the function
187 * return <code>PP_OK</code>. 187 * return <code>PP_OK</code>.
188 * 188 *
189 * @return In case of immediate failure, returns 189 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is
190 * <code>PP_ERROR_FAILED</code>. If a message is currently available, returns 190 * invoked with <code>PP_OK</code> or <code>PP_ERROR_FAILED</code>.
191 * <code>PP_OK</code>. Otherwise, returns <PP_OK_COMPLETIONPENDING</code> 191 * If an error is detected or connection is closed, returns
192 * and invokes <code>callback</code> later. At that case, if GetReadyState() 192 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
193 * returns <code>PP_WEBSOCKETREADYSTATE_OPEN</code>, the received 193 * Until buffered message become empty, continues to returns
194 * message is also copied to procided <code>message</code>. Otherwise, 194 * <code>PP_OK</code> as if connection is still established without errors.
195 * the connection is closed and ReceiveMessage() failed to receive a message.
196 */ 195 */
197 int32_t (*ReceiveMessage)(PP_Resource web_socket, 196 int32_t (*ReceiveMessage)(PP_Resource web_socket,
198 struct PP_Var* message, 197 struct PP_Var* message,
199 struct PP_CompletionCallback callback); 198 struct PP_CompletionCallback callback);
200 /** 199 /**
201 * SendMessage() sends a message to the WebSocket server. 200 * SendMessage() sends a message to the WebSocket server.
202 * 201 *
203 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 202 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
204 * WebSocket. 203 * WebSocket.
205 * 204 *
206 * @param[in] message A message to send. The message is copied to internal 205 * @param[in] message A message to send. The message is copied to internal
207 * buffer. So caller can free <code>message</code> safely after returning 206 * buffer. So caller can free <code>message</code> safely after returning
208 * from the function. 207 * from the function.
209 * 208 *
210 * @return In case of immediate failure, returns an error code as follows. 209 * @return In case of immediate failure, returns an error code as follows.
211 * Returns <code>PP_ERROR_FAILED</code> corresponding to JavaScript 210 * Returns <code>PP_ERROR_FAILED</code> corresponding to JavaScript
212 * InvalidStateError and <code>PP_ERROR_BADARGUMENT</code> corresponding to 211 * InvalidStateError and <code>PP_ERROR_BADARGUMENT</code> corresponding to
213 * JavaScript SyntaxError. Otherwise, return <code>PP_OK</code>. 212 * JavaScript SyntaxError. Otherwise, return <code>PP_OK</code>.
214 * <code>PP_OK</code> doesn't necessarily mean that the server received the 213 * <code>PP_OK</code> doesn't necessarily mean that the server received the
215 * message. 214 * message.
216 */ 215 */
217 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message); 216 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message);
218 /** 217 /**
219 * GetBufferedAmount() returns the number of bytes of text and binary 218 * GetBufferedAmount() returns the number of bytes of text and binary
220 * messages that have been queued for the WebSocket connection to send but 219 * messages that have been queued for the WebSocket connection to send but
221 * have not been transmitted to the network yet. 220 * have not been transmitted to the network yet.
222 * 221 *
223 * Note: This interface might not be able to return exact bytes in the first
224 * release. Current WebSocket implementation can not estimate exact protocol
225 * frame overheads.
226 *
227 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 222 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
228 * WebSocket. 223 * WebSocket.
229 * 224 *
230 * @return Returns the number of bytes. 225 * @return Returns the number of bytes.
231 */ 226 */
232 uint64_t (*GetBufferedAmount)(PP_Resource web_socket); 227 uint64_t (*GetBufferedAmount)(PP_Resource web_socket);
233 /** 228 /**
234 * GetCloseCode() returns the connection close code for the WebSocket 229 * GetCloseCode() returns the connection close code for the WebSocket
235 * connection. 230 * connection.
236 * 231 *
237 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 232 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
238 * WebSocket. 233 * WebSocket.
239 * 234 *
240 * @return Returns 0 if called before the close code is set. 235 * @return Returns 0 if called before the close code is set.
241 */ 236 */
242 uint16_t (*GetCloseCode)(PP_Resource web_socket); 237 uint16_t (*GetCloseCode)(PP_Resource web_socket);
243 /** 238 /**
244 * GetCloseReason() returns the connection close reason for the WebSocket 239 * GetCloseReason() returns the connection close reason for the WebSocket
245 * connection. 240 * connection.
246 * 241 *
247 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 242 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
248 * WebSocket. 243 * WebSocket.
249 * 244 *
250 * @return Returns a <code>PP_VARTYPE_STRING</code> var. if called before the 245 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
251 * close reason is set, its data is empty string. Returns a 246 * close reason is set, it contains empty string. Returns a
252 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 247 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
253 */ 248 */
254 struct PP_Var (*GetCloseReason)(PP_Resource web_socket); 249 struct PP_Var (*GetCloseReason)(PP_Resource web_socket);
255 /** 250 /**
256 * GetCloseWasClean() returns if the connection was closed cleanly for the 251 * GetCloseWasClean() returns if the connection was closed cleanly for the
257 * specified WebSocket connection. 252 * specified WebSocket connection.
258 * 253 *
259 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 254 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
260 * WebSocket. 255 * WebSocket.
261 * 256 *
(...skipping 17 matching lines...) Expand all
279 */ 274 */
280 struct PP_Var (*GetExtensions)(PP_Resource web_socket); 275 struct PP_Var (*GetExtensions)(PP_Resource web_socket);
281 /** 276 /**
282 * GetProtocol() returns the sub-protocol chosen by the server for the 277 * GetProtocol() returns the sub-protocol chosen by the server for the
283 * specified WebSocket connection. 278 * specified WebSocket connection.
284 * 279 *
285 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 280 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
286 * WebSocket. 281 * WebSocket.
287 * 282 *
288 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the 283 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
289 * connection is established, its data is empty string. Returns a 284 * connection is established, it contains empty string. Returns a
290 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 285 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
291 */ 286 */
292 struct PP_Var (*GetProtocol)(PP_Resource web_socket); 287 struct PP_Var (*GetProtocol)(PP_Resource web_socket);
293 /** 288 /**
294 * GetReadyState() returns the ready state of the specified WebSocket 289 * GetReadyState() returns the ready state of the specified WebSocket
295 * connection. 290 * connection.
296 * 291 *
297 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 292 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
298 * WebSocket. 293 * WebSocket.
299 * 294 *
300 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called 295 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called
301 * before connect() is called, or called on an invalid resource. 296 * before connect() is called, or called on an invalid resource.
302 */ 297 */
303 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket); 298 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket);
304 /** 299 /**
305 * GetURL() returns the URL associated with specified WebSocket connection. 300 * GetURL() returns the URL associated with specified WebSocket connection.
306 * 301 *
307 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 302 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
308 * WebSocket. 303 * WebSocket.
309 * 304 *
310 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the 305 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
311 * connection is established, its data is empty string. Return a 306 * connection is established, it contains empty string. Return a
312 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 307 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
313 */ 308 */
314 struct PP_Var (*GetURL)(PP_Resource web_socket); 309 struct PP_Var (*GetURL)(PP_Resource web_socket);
315 }; 310 };
316 /** 311 /**
317 * @} 312 * @}
318 */ 313 */
319 314
320 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ 315 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */
321 316
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698