| 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 ppb_websocket.idl modified Wed Apr 25 11:48:30 2012. */ | 6 /* From ppb_websocket.idl modified Tue May 15 18:32:39 2012. */ |
| 7 | 7 |
| 8 #ifndef PPAPI_C_PPB_WEBSOCKET_H_ | 8 #ifndef PPAPI_C_PPB_WEBSOCKET_H_ |
| 9 #define PPAPI_C_PPB_WEBSOCKET_H_ | 9 #define PPAPI_C_PPB_WEBSOCKET_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 * GetCloseCode(). Refer to RFC 6455, The WebSocket Protocol, for further | 65 * GetCloseCode(). Refer to RFC 6455, The WebSocket Protocol, for further |
| 66 * information. | 66 * information. |
| 67 * <code>PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE</code> and codes in the range | 67 * <code>PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE</code> and codes in the range |
| 68 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN</code> to | 68 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN</code> to |
| 69 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX</code>, and | 69 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX</code>, and |
| 70 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN</code> to | 70 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN</code> to |
| 71 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX</code> are valid for Close(). | 71 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX</code> are valid for Close(). |
| 72 */ | 72 */ |
| 73 typedef enum { | 73 typedef enum { |
| 74 /** | 74 /** |
| 75 * Indicates to request closing connection without status code. This code is |
| 76 * internally assigned in WebKit, and not based on any WebSocket related |
| 77 * specification. |
| 78 */ |
| 79 PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED = -1, |
| 80 /** |
| 75 * Status codes in the range 0-999 are not used. | 81 * Status codes in the range 0-999 are not used. |
| 76 */ | 82 */ |
| 77 /** | 83 /** |
| 78 * Indicates a normal closure. | 84 * Indicates a normal closure. |
| 79 */ | 85 */ |
| 80 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE = 1000, | 86 PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE = 1000, |
| 81 /** | 87 /** |
| 82 * Indicates that an endpoint is "going away", such as a server going down. | 88 * Indicates that an endpoint is "going away", such as a server going down. |
| 83 */ | 89 */ |
| 84 PP_WEBSOCKETSTATUSCODE_GOING_AWAY = 1001, | 90 PP_WEBSOCKETSTATUSCODE_GOING_AWAY = 1001, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 * IANA. | 156 * IANA. |
| 151 */ | 157 */ |
| 152 PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN = 3000, | 158 PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN = 3000, |
| 153 PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX = 3999, | 159 PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX = 3999, |
| 154 /** | 160 /** |
| 155 * Status codes in the range 4000-4999 are reserved for private use. | 161 * Status codes in the range 4000-4999 are reserved for private use. |
| 156 * Application can use these codes for application specific purposes freely. | 162 * Application can use these codes for application specific purposes freely. |
| 157 */ | 163 */ |
| 158 PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN = 4000, | 164 PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN = 4000, |
| 159 PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX = 4999 | 165 PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX = 4999 |
| 160 } PP_WebSocketCloseCode; | 166 } PP_WebSocketStatusCode; |
| 161 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketCloseCode, 4); | 167 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketStatusCode, 4); |
| 162 /** | 168 /** |
| 163 * @} | 169 * @} |
| 164 */ | 170 */ |
| 165 | 171 |
| 166 /** | 172 /** |
| 167 * @addtogroup Interfaces | 173 * @addtogroup Interfaces |
| 168 * @{ | 174 * @{ |
| 169 */ | 175 */ |
| 170 /** | 176 /** |
| 171 * The <code>PPB_WebSocket</code> interface provides bi-directional, | 177 * The <code>PPB_WebSocket</code> interface provides bi-directional, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const struct PP_Var protocols[], | 245 const struct PP_Var protocols[], |
| 240 uint32_t protocol_count, | 246 uint32_t protocol_count, |
| 241 struct PP_CompletionCallback callback); | 247 struct PP_CompletionCallback callback); |
| 242 /** | 248 /** |
| 243 * Close() closes the specified WebSocket connection by specifying | 249 * Close() closes the specified WebSocket connection by specifying |
| 244 * <code>code</code> and <code>reason</code>. | 250 * <code>code</code> and <code>reason</code>. |
| 245 * | 251 * |
| 246 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 252 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 247 * WebSocket. | 253 * WebSocket. |
| 248 * | 254 * |
| 249 * @param[in] code The WebSocket close code. This is ignored if it is 0. | 255 * @param[in] code The WebSocket close code. This is ignored if it is |
| 256 * <code>PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED</code>. |
| 250 * <code>PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE</code> must be used for the | 257 * <code>PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE</code> must be used for the |
| 251 * usual case. To indicate some specific error cases, codes in the range | 258 * usual case. To indicate some specific error cases, codes in the range |
| 252 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN</code> to | 259 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN</code> to |
| 253 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX</code>, and in the range | 260 * <code>PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX</code>, and in the range |
| 254 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN</code> to | 261 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN</code> to |
| 255 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX</code> are available. | 262 * <code>PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX</code> are available. |
| 256 * | 263 * |
| 257 * @param[in] reason A <code>PP_Var</code> representing the WebSocket | 264 * @param[in] reason A <code>PP_Var</code> representing the WebSocket |
| 258 * close reason. This is ignored if it is <code>PP_VARTYPE_UNDEFINED</code>. | 265 * close reason. This is ignored if it is <code>PP_VARTYPE_UNDEFINED</code>. |
| 259 * Otherwise, its <code>PP_VarType</code> must be | 266 * Otherwise, its <code>PP_VarType</code> must be |
| 260 * <code>PP_VARTYPE_STRING</code>. | 267 * <code>PP_VARTYPE_STRING</code>. |
| 261 * | 268 * |
| 262 * @param[in] callback A <code>PP_CompletionCallback</code> called | 269 * @param[in] callback A <code>PP_CompletionCallback</code> called |
| 263 * when the connection is closed or an error occurs in closing the | 270 * when the connection is closed or an error occurs in closing the |
| 264 * connection. | 271 * connection. |
| 265 * | 272 * |
| 266 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 273 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 267 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>reason</code> contains | 274 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>reason</code> contains |
| 268 * an invalid character as a UTF-8 string, or is longer than 123 bytes. | 275 * an invalid character as a UTF-8 string, or is longer than 123 bytes. |
| 269 * <code>PP_ERROR_BADARGUMENT</code> corresponds to a JavaScript SyntaxError | 276 * <code>PP_ERROR_BADARGUMENT</code> corresponds to a JavaScript SyntaxError |
| 270 * in the WebSocket API specification. | 277 * in the WebSocket API specification. |
| 271 * Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer | 278 * Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer |
| 272 * equal to 1000 or in the range 3000 to 4999. <code>PP_ERROR_NOACCESS</code> | 279 * equal to 1000 or in the range 3000 to 4999. <code>PP_ERROR_NOACCESS</code> |
| 273 * corresponds to an InvalidAccessError in the WebSocket API specification. | 280 * corresponds to an InvalidAccessError in the WebSocket API specification. |
| 274 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to Close() is | 281 * Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to Close() is |
| 275 * not finished. | 282 * not finished. |
| 276 */ | 283 */ |
| 277 int32_t (*Close)(PP_Resource web_socket, | 284 int32_t (*Close)(PP_Resource web_socket, |
| 278 uint16_t code, | 285 PP_WebSocketStatusCode code, |
| 279 struct PP_Var reason, | 286 struct PP_Var reason, |
| 280 struct PP_CompletionCallback callback); | 287 struct PP_CompletionCallback callback); |
| 281 /** | 288 /** |
| 282 * ReceiveMessage() receives a message from the WebSocket server. | 289 * ReceiveMessage() receives a message from the WebSocket server. |
| 283 * This interface only returns a single message. That is, this interface must | 290 * This interface only returns a single message. That is, this interface must |
| 284 * be called at least N times to receive N messages, no matter the size of | 291 * be called at least N times to receive N messages, no matter the size of |
| 285 * each message. | 292 * each message. |
| 286 * | 293 * |
| 287 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 294 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 288 * WebSocket. | 295 * WebSocket. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 struct PP_Var (*GetURL)(PP_Resource web_socket); | 432 struct PP_Var (*GetURL)(PP_Resource web_socket); |
| 426 }; | 433 }; |
| 427 | 434 |
| 428 typedef struct PPB_WebSocket_1_0 PPB_WebSocket; | 435 typedef struct PPB_WebSocket_1_0 PPB_WebSocket; |
| 429 /** | 436 /** |
| 430 * @} | 437 * @} |
| 431 */ | 438 */ |
| 432 | 439 |
| 433 #endif /* PPAPI_C_PPB_WEBSOCKET_H_ */ | 440 #endif /* PPAPI_C_PPB_WEBSOCKET_H_ */ |
| 434 | 441 |
| OLD | NEW |