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

Side by Side Diff: ppapi/c/ppb_websocket.h

Issue 9192009: WebSocket Pepper API: make the API out of dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for land Created 8 years, 10 months 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
« no previous file with comments | « ppapi/c/dev/ppb_websocket_dev.h ('k') | ppapi/cpp/dev/websocket_dev.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Fri Jan 27 10:09:34 2012. */ 6 /* From ppb_websocket.idl modified Fri Jan 27 15:51:19 2012. */
7 7
8 #ifndef PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ 8 #ifndef PPAPI_C_PPB_WEBSOCKET_H_
9 #define PPAPI_C_DEV_PPB_WEBSOCKET_DEV_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"
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_INTERFACE_1_0 "PPB_WebSocket;1.0"
20 #define PPB_WEBSOCKET_DEV_INTERFACE PPB_WEBSOCKET_DEV_INTERFACE_0_1 20 #define PPB_WEBSOCKET_INTERFACE PPB_WEBSOCKET_INTERFACE_1_0
21 21
22 /** 22 /**
23 * @file 23 * @file
24 * This file defines the <code>PPB_WebSocket_Dev</code> interface. 24 * This file defines the <code>PPB_WebSocket</code> interface.
25 */ 25 */
26 26
27 27
28 /** 28 /**
29 * @addtogroup Enums 29 * @addtogroup Enums
30 * @{ 30 * @{
31 */ 31 */
32 /** 32 /**
33 * This enumeration contains the types representing the WebSocket ready state 33 * This enumeration contains the types representing the WebSocket ready state
34 * and these states are based on the JavaScript WebSocket API specification. 34 * and these states are based on the JavaScript WebSocket API specification.
35 * GetReadyState() returns one of these states. 35 * GetReadyState() returns one of these states.
36 */ 36 */
37 typedef enum { 37 typedef enum {
38 /** 38 /**
39 * Ready state is queried on an invalid resource. 39 * Ready state is queried on an invalid resource.
40 */ 40 */
41 PP_WEBSOCKETREADYSTATE_INVALID_DEV = -1, 41 PP_WEBSOCKETREADYSTATE_INVALID = -1,
42 /** 42 /**
43 * Ready state that the connection has not yet been established. 43 * Ready state that the connection has not yet been established.
44 */ 44 */
45 PP_WEBSOCKETREADYSTATE_CONNECTING_DEV = 0, 45 PP_WEBSOCKETREADYSTATE_CONNECTING = 0,
46 /** 46 /**
47 * Ready state that the WebSocket connection is established and communication 47 * Ready state that the WebSocket connection is established and communication
48 * is possible. 48 * is possible.
49 */ 49 */
50 PP_WEBSOCKETREADYSTATE_OPEN_DEV = 1, 50 PP_WEBSOCKETREADYSTATE_OPEN = 1,
51 /** 51 /**
52 * Ready state that the connection is going through the closing handshake. 52 * Ready state that the connection is going through the closing handshake.
53 */ 53 */
54 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, 54 PP_WEBSOCKETREADYSTATE_CLOSING = 2,
55 /** 55 /**
56 * 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.
57 */ 57 */
58 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 58 PP_WEBSOCKETREADYSTATE_CLOSED = 3
59 } PP_WebSocketReadyState_Dev; 59 } PP_WebSocketReadyState;
60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); 60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState, 4);
61 /** 61 /**
62 * @} 62 * @}
63 */ 63 */
64 64
65 /** 65 /**
66 * @addtogroup Interfaces 66 * @addtogroup Interfaces
67 * @{ 67 * @{
68 */ 68 */
69 struct PPB_WebSocket_Dev_0_1 { 69 struct PPB_WebSocket_1_0 {
70 /** 70 /**
71 * Create() creates a WebSocket instance. 71 * Create() creates a WebSocket instance.
72 * 72 *
73 * @param[in] instance A <code>PP_Instance</code> identifying the instance 73 * @param[in] instance A <code>PP_Instance</code> identifying the instance
74 * with the WebSocket. 74 * with the WebSocket.
75 * 75 *
76 * @return A <code>PP_Resource</code> corresponding to a WebSocket if 76 * @return A <code>PP_Resource</code> corresponding to a WebSocket if
77 * successful. 77 * successful.
78 */ 78 */
79 PP_Resource (*Create)(PP_Instance instance); 79 PP_Resource (*Create)(PP_Instance instance);
80 /** 80 /**
81 * IsWebSocket() determines if the provided <code>resource</code> is a 81 * IsWebSocket() determines if the provided <code>resource</code> is a
82 * WebSocket instance. 82 * WebSocket instance.
83 * 83 *
84 * @param[in] resource A <code>PP_Resource</code> corresponding to a 84 * @param[in] resource A <code>PP_Resource</code> corresponding to a
85 * WebSocket. 85 * WebSocket.
86 * 86 *
87 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a 87 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a
88 * <code>PPB_WebSocket_Dev</code>, <code>PP_FALSE</code> if the 88 * <code>PPB_WebSocket</code>, <code>PP_FALSE</code> if the
89 * <code>resource</code> is invalid or some type other than 89 * <code>resource</code> is invalid or some type other than
90 * <code>PPB_WebSocket_Dev</code>. 90 * <code>PPB_WebSocket</code>.
91 */ 91 */
92 PP_Bool (*IsWebSocket)(PP_Resource resource); 92 PP_Bool (*IsWebSocket)(PP_Resource resource);
93 /** 93 /**
94 * Connect() connects to the specified WebSocket server. Caller can call this 94 * Connect() connects to the specified WebSocket server. Caller can call this
95 * method at most once for a <code>web_socket</code>. 95 * method at most once for a <code>web_socket</code>.
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.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 * 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
170 * message is. 170 * message is.
171 * 171 *
172 * @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
173 * WebSocket. 173 * WebSocket.
174 * 174 *
175 * @param[out] message The received message is copied to provided 175 * @param[out] message The received message is copied to provided
176 * <code>message</code>. The <code>message</code> must remain valid until 176 * <code>message</code>. The <code>message</code> must remain valid until
177 * the ReceiveMessage operation completes. Its <code>PP_VarType</code> 177 * the ReceiveMessage operation completes. Its <code>PP_VarType</code>
178 * will be <code>PP_VARTYPE_STRING</code> or 178 * will be <code>PP_VARTYPE_STRING</code> or
179 * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving. 179 * <code>PP_VARTYPE_ARRAY_BUFFER</code> on receiving.
180 * 180 *
181 * @param[in] callback A <code>PP_CompletionCallback</code> which is called 181 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
182 * when the receiving message is completed. It is ignored if ReceiveMessage 182 * when the receiving message is completed. It is ignored if ReceiveMessage
183 * completes synchronously and returns <code>PP_OK</code>. 183 * completes synchronously and returns <code>PP_OK</code>.
184 * 184 *
185 * @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>.
186 * If an error is detected or connection is closed, returns 186 * If an error is detected or connection is closed, returns
187 * <code>PP_ERROR_FAILED</code> after all buffered messages are received. 187 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
188 * Until buffered message become empty, continues to returns 188 * Until buffered message become empty, continues to returns
189 * <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.
190 */ 190 */
191 int32_t (*ReceiveMessage)(PP_Resource web_socket, 191 int32_t (*ReceiveMessage)(PP_Resource web_socket,
192 struct PP_Var* message, 192 struct PP_Var* message,
193 struct PP_CompletionCallback callback); 193 struct PP_CompletionCallback callback);
194 /** 194 /**
195 * SendMessage() sends a message to the WebSocket server. 195 * SendMessage() sends a message to the WebSocket server.
196 * 196 *
197 * @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
198 * WebSocket. 198 * WebSocket.
199 * 199 *
200 * @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
201 * buffer. So caller can free <code>message</code> safely after returning 201 * buffer. So caller can free <code>message</code> safely after returning
202 * from the function. Its <code>PP_VarType</code> must be 202 * from the function. Its <code>PP_VarType</code> must be
203 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>. 203 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>.
204 * 204 *
205 * @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>.
206 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is 206 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is
207 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds 207 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. It corresponds JavaScript
208 * JavaScript InvalidStateError of the specification. 208 * InvalidStateError of the specification.
209 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> 209 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code>
210 * 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
211 * corresponds to JavaScript SyntaxError of the specification. 211 * corresponds to JavaScript SyntaxError of the specification.
212 * 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
213 * that the server received the message. 213 * that the server received the message.
214 */ 214 */
215 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message); 215 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message);
216 /** 216 /**
217 * GetBufferedAmount() returns the number of bytes of text and binary 217 * GetBufferedAmount() returns the number of bytes of text and binary
218 * messages that have been queued for the WebSocket connection to send but 218 * messages that have been queued for the WebSocket connection to send but
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 284 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
285 */ 285 */
286 struct PP_Var (*GetProtocol)(PP_Resource web_socket); 286 struct PP_Var (*GetProtocol)(PP_Resource web_socket);
287 /** 287 /**
288 * GetReadyState() returns the ready state of the specified WebSocket 288 * GetReadyState() returns the ready state of the specified WebSocket
289 * connection. 289 * connection.
290 * 290 *
291 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 291 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
292 * WebSocket. 292 * WebSocket.
293 * 293 *
294 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called 294 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called
295 * before connect() is called, or called on an invalid resource. 295 * before connect() is called, or called on an invalid resource.
296 */ 296 */
297 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket); 297 PP_WebSocketReadyState (*GetReadyState)(PP_Resource web_socket);
298 /** 298 /**
299 * GetURL() returns the URL associated with specified WebSocket connection. 299 * GetURL() returns the URL associated with specified WebSocket connection.
300 * 300 *
301 * @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
302 * WebSocket. 302 * WebSocket.
303 * 303 *
304 * @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
305 * connection is established, it contains the empty string. Return a 305 * connection is established, it contains the empty string. Return a
306 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 306 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
307 */ 307 */
308 struct PP_Var (*GetURL)(PP_Resource web_socket); 308 struct PP_Var (*GetURL)(PP_Resource web_socket);
309 }; 309 };
310 310
311 typedef struct PPB_WebSocket_Dev_0_1 PPB_WebSocket_Dev; 311 typedef struct PPB_WebSocket_1_0 PPB_WebSocket;
312 /** 312 /**
313 * @} 313 * @}
314 */ 314 */
315 315
316 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ 316 #endif /* PPAPI_C_PPB_WEBSOCKET_H_ */
317 317
OLDNEW
« no previous file with comments | « ppapi/c/dev/ppb_websocket_dev.h ('k') | ppapi/cpp/dev/websocket_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698