| OLD | NEW |
| 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 /** | 6 /** |
| 7 * This file defines the <code>PPB_WebSocket_Dev</code> interface. | 7 * This file defines the <code>PPB_WebSocket_Dev</code> interface. |
| 8 */ | 8 */ |
| 9 label Chrome { | 9 label Chrome { |
| 10 M17 = 0.1 | 10 M17 = 0.1 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 * | 96 * |
| 97 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 97 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 98 * WebSocket. | 98 * WebSocket. |
| 99 * | 99 * |
| 100 * @param[in] url A <code>PP_Var</code> representing a WebSocket server URL. | 100 * @param[in] url A <code>PP_Var</code> representing a WebSocket server URL. |
| 101 * The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>. | 101 * The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>. |
| 102 * | 102 * |
| 103 * @param[in] protocols A pointer to an array of <code>PP_Var</code> | 103 * @param[in] protocols A pointer to an array of <code>PP_Var</code> |
| 104 * specifying sub-protocols. Each <code>PP_Var</code> represents one | 104 * specifying sub-protocols. Each <code>PP_Var</code> represents one |
| 105 * sub-protocol and its <code>PP_VarType</code> must be | 105 * sub-protocol and its <code>PP_VarType</code> must be |
| 106 * <code>PP_VARTYPE_STRING</code>. This argument can be null only if | 106 * <code>PP_VARTYPE_STRING</code>. |
| 107 * <code>protocol_count</code> is 0. | |
| 108 * | 107 * |
| 109 * @param[in] protocol_count The number of sub-protocols in | 108 * @param[in] protocol_count The number of sub-protocols in |
| 110 * <code>protocols</code>. | 109 * <code>protocols</code>. |
| 111 * | 110 * |
| 112 * @param[in] callback A <code>PP_CompletionCallback</code> which is called | 111 * @param[in] callback A <code>PP_CompletionCallback</code> which is called |
| 113 * when the connection is established or an error occurs in establishing | 112 * when the connection is established or an error occurs in establishing |
| 114 * connection. | 113 * connection. |
| 115 * | 114 * |
| 116 * @return In case of immediate failure, returns an error code as follows. | 115 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is |
| 117 * Returns <code>PP_ERROR_BADARGUMENT</code> corresponding to JavaScript | 116 * invoked with one of following results. |
| 118 * SyntaxError and <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript | 117 * <code>PP_ERROR_BADARGUMENT</code> corresponds to JavaScript SyntaxError, |
| 119 * SecurityError. Otherwise, returns <code>PP_OK_COMPLETIONPENDING</code> | 118 * <code>PP_ERROR_NOACCESS</code> corresponds to JavaScript SecurityError, |
| 120 * and invokes <code>callback</code> later. | 119 * and returns <code>PP_ERROR_INPROGRESS</code> if the call is not the first |
| 120 * time. |
| 121 */ | 121 */ |
| 122 int32_t Connect([in] PP_Resource web_socket, | 122 int32_t Connect([in] PP_Resource web_socket, |
| 123 [in] PP_Var url, | 123 [in] PP_Var url, |
| 124 [in, size_as=protocol_count] PP_Var[] protocols, | 124 [in, size_as=protocol_count] PP_Var[] protocols, |
| 125 [in] uint32_t protocol_count, | 125 [in] uint32_t protocol_count, |
| 126 [in] PP_CompletionCallback callback); | 126 [in] PP_CompletionCallback callback); |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Close() closes the specified WebSocket connection by specifying | 129 * Close() closes the specified WebSocket connection by specifying |
| 130 * <code>code</code> and <code>reason</code>. | 130 * <code>code</code> and <code>reason</code>. |
| 131 * | 131 * |
| 132 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 132 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 133 * WebSocket. | 133 * WebSocket. |
| 134 * | 134 * |
| 135 * @param[in] code The WebSocket close code. Ignored if it is 0. | 135 * @param[in] code The WebSocket close code. Ignored if it is 0. |
| 136 * | 136 * |
| 137 * @param[in] reason A <code>PP_Var</code> which represents the WebSocket | 137 * @param[in] reason A <code>PP_Var</code> which represents the WebSocket |
| 138 * close reason. Ignored if it is <code>PP_VARTYPE_UNDEFINED</code>. | 138 * close reason. Ignored if it is <code>PP_VARTYPE_UNDEFINED</code>. |
| 139 * Otherwise, its <code>PP_VarType</code> must be | 139 * Otherwise, its <code>PP_VarType</code> must be |
| 140 * <code>PP_VARTYPE_STRING</code>. | 140 * <code>PP_VARTYPE_STRING</code>. |
| 141 * | 141 * |
| 142 * @param[in] callback A <code>PP_CompletionCallback</code> which is called | 142 * @param[in] callback A <code>PP_CompletionCallback</code> which is called |
| 143 * when the connection is closed or an error occurs in closing connection. | 143 * when the connection is closed or an error occurs in closing connection. |
| 144 * | 144 * |
| 145 * @return In case of immediate failure, returns an error code as follows. | 145 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is |
| 146 * Returns <code>PP_ERROR_BADARGUMENT</code> corresponding to JavaScript | 146 * invoked with one of following results. |
| 147 * SyntaxError and <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript | 147 * <code>PP_ERROR_BADARGUMENT</code> corresponds to JavaScript SyntaxError, |
| 148 * InvalidAccessError. Otherwise, returns | 148 * <code>PP_ERROR_NOACCESS</code> corresponding to JavaScript |
| 149 * <code>PP_OK_COMPLETIONPENDING</code> and invokes <code>callback</code> | 149 * InvalidAccessError. Returns <code>PP_ERROR_INPROGRESS</code> if the call |
| 150 * later. | 150 * is not the first time. |
| 151 */ | 151 */ |
| 152 int32_t Close([in] PP_Resource web_socket, | 152 int32_t Close([in] PP_Resource web_socket, |
| 153 [in] uint16_t code, | 153 [in] uint16_t code, |
| 154 [in] PP_Var reason, | 154 [in] PP_Var reason, |
| 155 [in] PP_CompletionCallback callback); | 155 [in] PP_CompletionCallback callback); |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * ReceiveMessage() receives a message from the WebSocket server. | 158 * ReceiveMessage() receives a message from the WebSocket server. |
| 159 * This interface only returns bytes of a single message. That is, this | 159 * This interface only returns bytes of a single message. That is, this |
| 160 * interface must be called at least N times to receive N messages, no matter | 160 * interface must be called at least N times to receive N messages, no matter |
| 161 * how small each message is. | 161 * how small each message is. |
| 162 * | 162 * |
| 163 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 163 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 164 * WebSocket. | 164 * WebSocket. |
| 165 * | 165 * |
| 166 * @param[out] message The received message is copied to provided | 166 * @param[out] message The received message is copied to provided |
| 167 * <code>message</code>. | 167 * <code>message</code>. |
| 168 * | 168 * |
| 169 * @param[in] callback A <code>PP_CompletionCallback</code> which is called | 169 * @param[in] callback A <code>PP_CompletionCallback</code> which is called |
| 170 * when the receiving message is completed. It is ignored when the function | 170 * when the receiving message is completed. It is ignored when the function |
| 171 * return <code>PP_OK</code>. | 171 * return <code>PP_OK</code>. |
| 172 * | 172 * |
| 173 * @return In case of immediate failure, returns | 173 * @return Returns <code>PP_OK_COMPLETIONPENDING</code> then callback is |
| 174 * <code>PP_ERROR_FAILED</code>. If a message is currently available, returns | 174 * invoked with <code>PP_OK</code> or <code>PP_ERROR_FAILED</code>. |
| 175 * <code>PP_OK</code>. Otherwise, returns <PP_OK_COMPLETIONPENDING</code> | 175 * If an error is detected or connection is closed, returns |
| 176 * and invokes <code>callback</code> later. At that case, if GetReadyState() | 176 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. |
| 177 * returns <code>PP_WEBSOCKETREADYSTATE_OPEN</code>, the received | 177 * Until buffered message become empty, continues to returns |
| 178 * message is also copied to procided <code>message</code>. Otherwise, | 178 * <code>PP_OK</code> as if connection is still established without errors. |
| 179 * the connection is closed and ReceiveMessage() failed to receive a message. | |
| 180 */ | 179 */ |
| 181 int32_t ReceiveMessage([in] PP_Resource web_socket, | 180 int32_t ReceiveMessage([in] PP_Resource web_socket, |
| 182 [out] PP_Var message, | 181 [out] PP_Var message, |
| 183 [in] PP_CompletionCallback callback); | 182 [in] PP_CompletionCallback callback); |
| 184 | 183 |
| 185 /** | 184 /** |
| 186 * SendMessage() sends a message to the WebSocket server. | 185 * SendMessage() sends a message to the WebSocket server. |
| 187 * | 186 * |
| 188 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 187 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 189 * WebSocket. | 188 * WebSocket. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 200 * message. | 199 * message. |
| 201 */ | 200 */ |
| 202 int32_t SendMessage([in] PP_Resource web_socket, | 201 int32_t SendMessage([in] PP_Resource web_socket, |
| 203 [in] PP_Var message); | 202 [in] PP_Var message); |
| 204 | 203 |
| 205 /** | 204 /** |
| 206 * GetBufferedAmount() returns the number of bytes of text and binary | 205 * GetBufferedAmount() returns the number of bytes of text and binary |
| 207 * messages that have been queued for the WebSocket connection to send but | 206 * messages that have been queued for the WebSocket connection to send but |
| 208 * have not been transmitted to the network yet. | 207 * have not been transmitted to the network yet. |
| 209 * | 208 * |
| 210 * Note: This interface might not be able to return exact bytes in the first | |
| 211 * release. Current WebSocket implementation can not estimate exact protocol | |
| 212 * frame overheads. | |
| 213 * | |
| 214 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 209 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 215 * WebSocket. | 210 * WebSocket. |
| 216 * | 211 * |
| 217 * @return Returns the number of bytes. | 212 * @return Returns the number of bytes. |
| 218 */ | 213 */ |
| 219 uint64_t GetBufferedAmount([in] PP_Resource web_socket); | 214 uint64_t GetBufferedAmount([in] PP_Resource web_socket); |
| 220 | 215 |
| 221 /** | 216 /** |
| 222 * GetCloseCode() returns the connection close code for the WebSocket | 217 * GetCloseCode() returns the connection close code for the WebSocket |
| 223 * connection. | 218 * connection. |
| 224 * | 219 * |
| 225 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 220 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 226 * WebSocket. | 221 * WebSocket. |
| 227 * | 222 * |
| 228 * @return Returns 0 if called before the close code is set. | 223 * @return Returns 0 if called before the close code is set. |
| 229 */ | 224 */ |
| 230 uint16_t GetCloseCode([in] PP_Resource web_socket); | 225 uint16_t GetCloseCode([in] PP_Resource web_socket); |
| 231 | 226 |
| 232 /** | 227 /** |
| 233 * GetCloseReason() returns the connection close reason for the WebSocket | 228 * GetCloseReason() returns the connection close reason for the WebSocket |
| 234 * connection. | 229 * connection. |
| 235 * | 230 * |
| 236 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 231 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 237 * WebSocket. | 232 * WebSocket. |
| 238 * | 233 * |
| 239 * @return Returns a <code>PP_VARTYPE_STRING</code> var. if called before the | 234 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the |
| 240 * close reason is set, its data is empty string. Returns a | 235 * close reason is set, it contains empty string. Returns a |
| 241 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. | 236 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. |
| 242 */ | 237 */ |
| 243 PP_Var GetCloseReason([in] PP_Resource web_socket); | 238 PP_Var GetCloseReason([in] PP_Resource web_socket); |
| 244 | 239 |
| 245 /** | 240 /** |
| 246 * GetCloseWasClean() returns if the connection was closed cleanly for the | 241 * GetCloseWasClean() returns if the connection was closed cleanly for the |
| 247 * specified WebSocket connection. | 242 * specified WebSocket connection. |
| 248 * | 243 * |
| 249 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 244 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 250 * WebSocket. | 245 * WebSocket. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 271 PP_Var GetExtensions([in] PP_Resource web_socket); | 266 PP_Var GetExtensions([in] PP_Resource web_socket); |
| 272 | 267 |
| 273 /** | 268 /** |
| 274 * GetProtocol() returns the sub-protocol chosen by the server for the | 269 * GetProtocol() returns the sub-protocol chosen by the server for the |
| 275 * specified WebSocket connection. | 270 * specified WebSocket connection. |
| 276 * | 271 * |
| 277 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 272 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 278 * WebSocket. | 273 * WebSocket. |
| 279 * | 274 * |
| 280 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the | 275 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the |
| 281 * connection is established, its data is empty string. Returns a | 276 * connection is established, it contains empty string. Returns a |
| 282 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. | 277 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. |
| 283 */ | 278 */ |
| 284 PP_Var GetProtocol([in] PP_Resource web_socket); | 279 PP_Var GetProtocol([in] PP_Resource web_socket); |
| 285 | 280 |
| 286 /** | 281 /** |
| 287 * GetReadyState() returns the ready state of the specified WebSocket | 282 * GetReadyState() returns the ready state of the specified WebSocket |
| 288 * connection. | 283 * connection. |
| 289 * | 284 * |
| 290 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 285 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 291 * WebSocket. | 286 * WebSocket. |
| 292 * | 287 * |
| 293 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called | 288 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called |
| 294 * before connect() is called, or called on an invalid resource. | 289 * before connect() is called, or called on an invalid resource. |
| 295 */ | 290 */ |
| 296 PP_WebSocketReadyState_Dev GetReadyState([in] PP_Resource web_socket); | 291 PP_WebSocketReadyState_Dev GetReadyState([in] PP_Resource web_socket); |
| 297 | 292 |
| 298 /** | 293 /** |
| 299 * GetURL() returns the URL associated with specified WebSocket connection. | 294 * GetURL() returns the URL associated with specified WebSocket connection. |
| 300 * | 295 * |
| 301 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a | 296 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a |
| 302 * WebSocket. | 297 * WebSocket. |
| 303 * | 298 * |
| 304 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the | 299 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the |
| 305 * connection is established, its data is empty string. Return a | 300 * connection is established, it contains empty string. Return a |
| 306 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. | 301 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. |
| 307 */ | 302 */ |
| 308 PP_Var GetURL([in] PP_Resource web_socket); | 303 PP_Var GetURL([in] PP_Resource web_socket); |
| 309 }; | 304 }; |
| OLD | NEW |