| 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 /** | 6 /** |
| 7 * This file defines the <code>PPB_WebSocket_Dev</code> interface. | 7 * This file defines the <code>PPB_WebSocket</code> interface. |
| 8 */ | 8 */ |
| 9 label Chrome { | 9 label Chrome { |
| 10 M17 = 0.1 | 10 M18 = 1.0 |
| 11 }; | 11 }; |
| 12 | 12 |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * This enumeration contains the types representing the WebSocket ready state | 15 * This enumeration contains the types representing the WebSocket ready state |
| 16 * and these states are based on the JavaScript WebSocket API specification. | 16 * and these states are based on the JavaScript WebSocket API specification. |
| 17 * GetReadyState() returns one of these states. | 17 * GetReadyState() returns one of these states. |
| 18 */ | 18 */ |
| 19 [assert_size(4)] | 19 [assert_size(4)] |
| 20 enum PP_WebSocketReadyState_Dev { | 20 enum PP_WebSocketReadyState { |
| 21 /** | 21 /** |
| 22 * Ready state is queried on an invalid resource. | 22 * Ready state is queried on an invalid resource. |
| 23 */ | 23 */ |
| 24 PP_WEBSOCKETREADYSTATE_INVALID_DEV = -1, | 24 PP_WEBSOCKETREADYSTATE_INVALID = -1, |
| 25 /** | 25 /** |
| 26 * Ready state that the connection has not yet been established. | 26 * Ready state that the connection has not yet been established. |
| 27 */ | 27 */ |
| 28 PP_WEBSOCKETREADYSTATE_CONNECTING_DEV = 0, | 28 PP_WEBSOCKETREADYSTATE_CONNECTING = 0, |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Ready state that the WebSocket connection is established and communication | 31 * Ready state that the WebSocket connection is established and communication |
| 32 * is possible. | 32 * is possible. |
| 33 */ | 33 */ |
| 34 PP_WEBSOCKETREADYSTATE_OPEN_DEV = 1, | 34 PP_WEBSOCKETREADYSTATE_OPEN = 1, |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Ready state that the connection is going through the closing handshake. | 37 * Ready state that the connection is going through the closing handshake. |
| 38 */ | 38 */ |
| 39 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, | 39 PP_WEBSOCKETREADYSTATE_CLOSING = 2, |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Ready state that the connection has been closed or could not be opened. | 42 * Ready state that the connection has been closed or could not be opened. |
| 43 */ | 43 */ |
| 44 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 | 44 PP_WEBSOCKETREADYSTATE_CLOSED = 3 |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 interface PPB_WebSocket_Dev { | 47 interface PPB_WebSocket { |
| 48 /** | 48 /** |
| 49 * Create() creates a WebSocket instance. | 49 * Create() creates a WebSocket instance. |
| 50 * | 50 * |
| 51 * @param[in] instance A <code>PP_Instance</code> identifying the instance | 51 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 52 * with the WebSocket. | 52 * with the WebSocket. |
| 53 * | 53 * |
| 54 * @return A <code>PP_Resource</code> corresponding to a WebSocket if | 54 * @return A <code>PP_Resource</code> corresponding to a WebSocket if |
| 55 * successful. | 55 * successful. |
| 56 */ | 56 */ |
| 57 PP_Resource Create([in] PP_Instance instance); | 57 PP_Resource Create([in] PP_Instance instance); |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * IsWebSocket() determines if the provided <code>resource</code> is a | 60 * IsWebSocket() determines if the provided <code>resource</code> is a |
| 61 * WebSocket instance. | 61 * WebSocket instance. |
| 62 * | 62 * |
| 63 * @param[in] resource A <code>PP_Resource</code> corresponding to a | 63 * @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 64 * WebSocket. | 64 * WebSocket. |
| 65 * | 65 * |
| 66 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a | 66 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a |
| 67 * <code>PPB_WebSocket_Dev</code>, <code>PP_FALSE</code> if the | 67 * <code>PPB_WebSocket</code>, <code>PP_FALSE</code> if the |
| 68 * <code>resource</code> is invalid or some type other than | 68 * <code>resource</code> is invalid or some type other than |
| 69 * <code>PPB_WebSocket_Dev</code>. | 69 * <code>PPB_WebSocket</code>. |
| 70 */ | 70 */ |
| 71 PP_Bool IsWebSocket([in] PP_Resource resource); | 71 PP_Bool IsWebSocket([in] PP_Resource resource); |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Connect() connects to the specified WebSocket server. Caller can call this | 74 * Connect() connects to the specified WebSocket server. Caller can call this |
| 75 * method at most once for a <code>web_socket</code>. | 75 * method at most once for a <code>web_socket</code>. |
| 76 * | 76 * |
| 77 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 77 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 78 * WebSocket. | 78 * WebSocket. |
| 79 * | 79 * |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 * be called at least N times to receive N messages, no matter how small each | 151 * be called at least N times to receive N messages, no matter how small each |
| 152 * message is. | 152 * message is. |
| 153 * | 153 * |
| 154 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 154 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 155 * WebSocket. | 155 * WebSocket. |
| 156 * | 156 * |
| 157 * @param[out] message The received message is copied to provided | 157 * @param[out] message The received message is copied to provided |
| 158 * <code>message</code>. The <code>message</code> must remain valid until | 158 * <code>message</code>. The <code>message</code> must remain valid until |
| 159 * the ReceiveMessage operation completes. Its <code>PP_VarType</code> | 159 * the ReceiveMessage operation completes. Its <code>PP_VarType</code> |
| 160 * will be <code>PP_VARTYPE_STRING</code> or | 160 * will be <code>PP_VARTYPE_STRING</code> or |
| 161 * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving. | 161 * <code>PP_VARTYPE_ARRAY_BUFFER</code> on receiving. |
| 162 * | 162 * |
| 163 * @param[in] callback A <code>PP_CompletionCallback</code> which is called | 163 * @param[in] callback A <code>PP_CompletionCallback</code> which is called |
| 164 * when the receiving message is completed. It is ignored if ReceiveMessage | 164 * when the receiving message is completed. It is ignored if ReceiveMessage |
| 165 * completes synchronously and returns <code>PP_OK</code>. | 165 * completes synchronously and returns <code>PP_OK</code>. |
| 166 * | 166 * |
| 167 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 167 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 168 * If an error is detected or connection is closed, returns | 168 * If an error is detected or connection is closed, returns |
| 169 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. | 169 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
| 170 * Until buffered message become empty, continues to returns | 170 * Until buffered message become empty, continues to returns |
| 171 * <code>PP_OK</code> as if connection is still established without errors. | 171 * <code>PP_OK</code> as if connection is still established without errors. |
| 172 */ | 172 */ |
| 173 int32_t ReceiveMessage([in] PP_Resource web_socket, | 173 int32_t ReceiveMessage([in] PP_Resource web_socket, |
| 174 [out] PP_Var message, | 174 [out] PP_Var message, |
| 175 [in] PP_CompletionCallback callback); | 175 [in] PP_CompletionCallback callback); |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * SendMessage() sends a message to the WebSocket server. | 178 * SendMessage() sends a message to the WebSocket server. |
| 179 * | 179 * |
| 180 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 180 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 181 * WebSocket. | 181 * WebSocket. |
| 182 * | 182 * |
| 183 * @param[in] message A message to send. The message is copied to internal | 183 * @param[in] message A message to send. The message is copied to internal |
| 184 * buffer. So caller can free <code>message</code> safely after returning | 184 * buffer. So caller can free <code>message</code> safely after returning |
| 185 * from the function. Its <code>PP_VarType</code> must be | 185 * from the function. Its <code>PP_VarType</code> must be |
| 186 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>. | 186 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>. |
| 187 * | 187 * |
| 188 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 188 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 189 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is | 189 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is |
| 190 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds | 190 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. It corresponds JavaScript |
| 191 * JavaScript InvalidStateError of the specification. | 191 * InvalidStateError of the specification. |
| 192 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> | 192 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> |
| 193 * of string type contains an invalid character as a UTF-8 string. It | 193 * of string type contains an invalid character as a UTF-8 string. It |
| 194 * corresponds to JavaScript SyntaxError of the specification. | 194 * corresponds to JavaScript SyntaxError of the specification. |
| 195 * Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean | 195 * Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean |
| 196 * that the server received the message. | 196 * that the server received the message. |
| 197 */ | 197 */ |
| 198 int32_t SendMessage([in] PP_Resource web_socket, | 198 int32_t SendMessage([in] PP_Resource web_socket, |
| 199 [in] PP_Var message); | 199 [in] PP_Var message); |
| 200 | 200 |
| 201 /** | 201 /** |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 */ | 275 */ |
| 276 PP_Var GetProtocol([in] PP_Resource web_socket); | 276 PP_Var GetProtocol([in] PP_Resource web_socket); |
| 277 | 277 |
| 278 /** | 278 /** |
| 279 * GetReadyState() returns the ready state of the specified WebSocket | 279 * GetReadyState() returns the ready state of the specified WebSocket |
| 280 * connection. | 280 * connection. |
| 281 * | 281 * |
| 282 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 282 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 283 * WebSocket. | 283 * WebSocket. |
| 284 * | 284 * |
| 285 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called | 285 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called |
| 286 * before connect() is called, or called on an invalid resource. | 286 * before connect() is called, or called on an invalid resource. |
| 287 */ | 287 */ |
| 288 PP_WebSocketReadyState_Dev GetReadyState([in] PP_Resource web_socket); | 288 PP_WebSocketReadyState GetReadyState([in] PP_Resource web_socket); |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * GetURL() returns the URL associated with specified WebSocket connection. | 291 * GetURL() returns the URL associated with specified WebSocket connection. |
| 292 * | 292 * |
| 293 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 293 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 294 * WebSocket. | 294 * WebSocket. |
| 295 * | 295 * |
| 296 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the | 296 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the |
| 297 * connection is established, it contains the empty string. Return a | 297 * connection is established, it contains the empty string. Return a |
| 298 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. | 298 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. |
| 299 */ | 299 */ |
| 300 PP_Var GetURL([in] PP_Resource web_socket); | 300 PP_Var GetURL([in] PP_Resource web_socket); |
| 301 }; | 301 }; |
| OLD | NEW |