| OLD | NEW |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 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 Jan 18 20:17:45 2012. */ | 6 /* From dev/ppb_websocket_dev.idl modified Fri Jan 27 10:09:34 2012. */ |
| 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" |
| 17 #include "ppapi/c/pp_var.h" | 17 #include "ppapi/c/pp_var.h" |
| 18 | 18 |
| 19 #define PPB_WEBSOCKET_DEV_INTERFACE_0_1 "PPB_WebSocket(Dev);0.1" | 19 #define PPB_WEBSOCKET_DEV_INTERFACE_0_1 "PPB_WebSocket(Dev);0.1" |
| 20 #define PPB_WEBSOCKET_DEV_INTERFACE_0_9 "PPB_WebSocket(Dev);0.9" | 20 #define PPB_WEBSOCKET_DEV_INTERFACE PPB_WEBSOCKET_DEV_INTERFACE_0_1 |
| 21 #define PPB_WEBSOCKET_DEV_INTERFACE PPB_WEBSOCKET_DEV_INTERFACE_0_9 | |
| 22 | 21 |
| 23 /** | 22 /** |
| 24 * @file | 23 * @file |
| 25 * This file defines the <code>PPB_WebSocket_Dev</code> interface. | 24 * This file defines the <code>PPB_WebSocket_Dev</code> interface. |
| 26 */ | 25 */ |
| 27 | 26 |
| 28 | 27 |
| 29 /** | 28 /** |
| 30 * @addtogroup Enums | 29 * @addtogroup Enums |
| 31 * @{ | 30 * @{ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 52 /** | 51 /** |
| 53 * Ready state that the connection is going through the closing handshake. | 52 * Ready state that the connection is going through the closing handshake. |
| 54 */ | 53 */ |
| 55 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, | 54 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, |
| 56 /** | 55 /** |
| 57 * Ready state that the connection has been closed or could not be opened. | 56 * Ready state that the connection has been closed or could not be opened. |
| 58 */ | 57 */ |
| 59 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 | 58 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 |
| 60 } PP_WebSocketReadyState_Dev; | 59 } PP_WebSocketReadyState_Dev; |
| 61 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); | 60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); |
| 62 | |
| 63 /** | |
| 64 * This enumeration contains the types representing the WebSocket binary type | |
| 65 * to receive frames. These types are based on the JavaScript WebSocket API | |
| 66 * specification. | |
| 67 */ | |
| 68 typedef enum { | |
| 69 /** | |
| 70 * Binary type is queried on an invalid resource. | |
| 71 */ | |
| 72 PP_WEBSOCKETBINARYTYPE_INVALID = -1, | |
| 73 /** | |
| 74 * Binary type that represents Blob objects. | |
| 75 */ | |
| 76 PP_WEBSOCKETBINARYTYPE_BLOB_DEV = 0, | |
| 77 /** | |
| 78 * Binary type that represents ArrayBuffer objects. | |
| 79 */ | |
| 80 PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV = 1 | |
| 81 } PP_WebSocketBinaryType_Dev; | |
| 82 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketBinaryType_Dev, 4); | |
| 83 /** | 61 /** |
| 84 * @} | 62 * @} |
| 85 */ | 63 */ |
| 86 | 64 |
| 87 /** | 65 /** |
| 88 * @addtogroup Interfaces | 66 * @addtogroup Interfaces |
| 89 * @{ | 67 * @{ |
| 90 */ | 68 */ |
| 91 struct PPB_WebSocket_Dev_0_9 { | 69 struct PPB_WebSocket_Dev_0_1 { |
| 92 /** | 70 /** |
| 93 * Create() creates a WebSocket instance. | 71 * Create() creates a WebSocket instance. |
| 94 * | 72 * |
| 95 * @param[in] instance A <code>PP_Instance</code> identifying the instance | 73 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 96 * with the WebSocket. | 74 * with the WebSocket. |
| 97 * | 75 * |
| 98 * @return A <code>PP_Resource</code> corresponding to a WebSocket if | 76 * @return A <code>PP_Resource</code> corresponding to a WebSocket if |
| 99 * successful. | 77 * successful. |
| 100 */ | 78 */ |
| 101 PP_Resource (*Create)(PP_Instance instance); | 79 PP_Resource (*Create)(PP_Instance instance); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 * ReceiveMessage() receives a message from the WebSocket server. | 167 * ReceiveMessage() receives a message from the WebSocket server. |
| 190 * This interface only returns a single message. That is, this interface must | 168 * This interface only returns a single message. That is, this interface must |
| 191 * be called at least N times to receive N messages, no matter how small each | 169 * be called at least N times to receive N messages, no matter how small each |
| 192 * message is. | 170 * message is. |
| 193 * | 171 * |
| 194 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 172 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 195 * WebSocket. | 173 * WebSocket. |
| 196 * | 174 * |
| 197 * @param[out] message The received message is copied to provided | 175 * @param[out] message The received message is copied to provided |
| 198 * <code>message</code>. The <code>message</code> must remain valid until | 176 * <code>message</code>. The <code>message</code> must remain valid until |
| 199 * the ReceiveMessage operation completes. | 177 * the ReceiveMessage operation completes. Its <code>PP_VarType</code> |
| 178 * will be <code>PP_VARTYPE_STRING</code> or |
| 179 * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving. |
| 200 * | 180 * |
| 201 * @param[in] callback A <code>PP_CompletionCallback</code> which is called | 181 * @param[in] callback A <code>PP_CompletionCallback</code> which is called |
| 202 * when the receiving message is completed. It is ignored if ReceiveMessage | 182 * when the receiving message is completed. It is ignored if ReceiveMessage |
| 203 * completes synchronously and returns <code>PP_OK</code>. | 183 * completes synchronously and returns <code>PP_OK</code>. |
| 204 * | 184 * |
| 205 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 185 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 206 * If an error is detected or connection is closed, returns | 186 * If an error is detected or connection is closed, returns |
| 207 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. | 187 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
| 208 * Until buffered message become empty, continues to returns | 188 * Until buffered message become empty, continues to returns |
| 209 * <code>PP_OK</code> as if connection is still established without errors. | 189 * <code>PP_OK</code> as if connection is still established without errors. |
| 210 */ | 190 */ |
| 211 int32_t (*ReceiveMessage)(PP_Resource web_socket, | 191 int32_t (*ReceiveMessage)(PP_Resource web_socket, |
| 212 struct PP_Var* message, | 192 struct PP_Var* message, |
| 213 struct PP_CompletionCallback callback); | 193 struct PP_CompletionCallback callback); |
| 214 /** | 194 /** |
| 215 * SendMessage() sends a message to the WebSocket server. | 195 * SendMessage() sends a message to the WebSocket server. |
| 216 * | 196 * |
| 217 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 197 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 218 * WebSocket. | 198 * WebSocket. |
| 219 * | 199 * |
| 220 * @param[in] message A message to send. The message is copied to internal | 200 * @param[in] message A message to send. The message is copied to internal |
| 221 * buffer. So caller can free <code>message</code> safely after returning | 201 * buffer. So caller can free <code>message</code> safely after returning |
| 222 * from the function. | 202 * from the function. Its <code>PP_VarType</code> must be |
| 203 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>. |
| 223 * | 204 * |
| 224 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 205 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 225 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is | 206 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is |
| 226 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds | 207 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds |
| 227 * JavaScript InvalidStateError of the specification. | 208 * JavaScript InvalidStateError of the specification. |
| 228 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> | 209 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> |
| 229 * of string type contains an invalid character as a UTF-8 string. It | 210 * of string type contains an invalid character as a UTF-8 string. It |
| 230 * corresponds to JavaScript SyntaxError of the specification. | 211 * corresponds to JavaScript SyntaxError of the specification. |
| 231 * Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean | 212 * Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean |
| 232 * that the server received the message. | 213 * that the server received the message. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 * GetURL() returns the URL associated with specified WebSocket connection. | 299 * GetURL() returns the URL associated with specified WebSocket connection. |
| 319 * | 300 * |
| 320 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 301 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 321 * WebSocket. | 302 * WebSocket. |
| 322 * | 303 * |
| 323 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the | 304 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the |
| 324 * connection is established, it contains the empty string. Return a | 305 * connection is established, it contains the empty string. Return a |
| 325 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. | 306 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. |
| 326 */ | 307 */ |
| 327 struct PP_Var (*GetURL)(PP_Resource web_socket); | 308 struct PP_Var (*GetURL)(PP_Resource web_socket); |
| 328 /** | |
| 329 * SetBinaryType() specifies the binary object type for receiving binary | |
| 330 * frames representation. Receiving text frames are always mapped to | |
| 331 * <PP_VARTYPE_STRING</code> var regardless of this attribute. | |
| 332 * This function should be called before Connect() to ensure receiving all | |
| 333 * incoming binary frames as the specified binary object type. | |
| 334 * Default type is <code>PP_WEBSOCKETBINARYTYPE_BLOB_DEV</code>. | |
| 335 * | |
| 336 * Currently, Blob bindings is not supported in Pepper, so receiving binary | |
| 337 * type is always ArrayBuffer. To ensure backward compatibility, you must | |
| 338 * call this function with | |
| 339 * <code>PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV</code> to use binary frames. | |
| 340 * | |
| 341 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | |
| 342 * WebSocket. | |
| 343 * | |
| 344 * @param[in] binary_type Binary object type for receiving binary frames | |
| 345 * representation. | |
| 346 * | |
| 347 * @return Returns <code>PP_FALSE</code> if the specified type is not | |
| 348 * supported. Otherwise, returns <code>PP_TRUE</code>. | |
| 349 */ | |
| 350 PP_Bool (*SetBinaryType)(PP_Resource web_socket, | |
| 351 PP_WebSocketBinaryType_Dev binary_type); | |
| 352 /** | |
| 353 * GetBinaryType() returns the currently specified binary object type for | |
| 354 * receiving binary frames. | |
| 355 * | |
| 356 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | |
| 357 * WebSocket. | |
| 358 * | |
| 359 * @return Returns <code>PP_WebSocketBinaryType_Dev</code> represents the | |
| 360 * current binary object type. | |
| 361 */ | |
| 362 PP_WebSocketBinaryType_Dev (*GetBinaryType)(PP_Resource web_socket); | |
| 363 }; | 309 }; |
| 364 | 310 |
| 365 typedef struct PPB_WebSocket_Dev_0_9 PPB_WebSocket_Dev; | 311 typedef struct PPB_WebSocket_Dev_0_1 PPB_WebSocket_Dev; |
| 366 | |
| 367 struct PPB_WebSocket_Dev_0_1 { | |
| 368 PP_Resource (*Create)(PP_Instance instance); | |
| 369 PP_Bool (*IsWebSocket)(PP_Resource resource); | |
| 370 int32_t (*Connect)(PP_Resource web_socket, | |
| 371 struct PP_Var url, | |
| 372 const struct PP_Var protocols[], | |
| 373 uint32_t protocol_count, | |
| 374 struct PP_CompletionCallback callback); | |
| 375 int32_t (*Close)(PP_Resource web_socket, | |
| 376 uint16_t code, | |
| 377 struct PP_Var reason, | |
| 378 struct PP_CompletionCallback callback); | |
| 379 int32_t (*ReceiveMessage)(PP_Resource web_socket, | |
| 380 struct PP_Var* message, | |
| 381 struct PP_CompletionCallback callback); | |
| 382 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message); | |
| 383 uint64_t (*GetBufferedAmount)(PP_Resource web_socket); | |
| 384 uint16_t (*GetCloseCode)(PP_Resource web_socket); | |
| 385 struct PP_Var (*GetCloseReason)(PP_Resource web_socket); | |
| 386 PP_Bool (*GetCloseWasClean)(PP_Resource web_socket); | |
| 387 struct PP_Var (*GetExtensions)(PP_Resource web_socket); | |
| 388 struct PP_Var (*GetProtocol)(PP_Resource web_socket); | |
| 389 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket); | |
| 390 struct PP_Var (*GetURL)(PP_Resource web_socket); | |
| 391 }; | |
| 392 /** | 312 /** |
| 393 * @} | 313 * @} |
| 394 */ | 314 */ |
| 395 | 315 |
| 396 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ | 316 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ |
| 397 | 317 |
| OLD | NEW |