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

Side by Side Diff: ppapi/c/dev/ppb_websocket_dev.h

Issue 8989046: WebSocket Pepper API: add interfaces to handle binaryType attribute (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/2011/2012/g Created 8 years, 11 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
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 Mon Dec 19 19:44:12 2011. */ 6 /* From dev/ppb_websocket_dev.idl modified Tue Jan 10 19:47:47 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 PPB_WEBSOCKET_DEV_INTERFACE_0_1 20 #define PPB_WEBSOCKET_DEV_INTERFACE_0_9 "PPB_WebSocket(Dev);0.9"
21 #define PPB_WEBSOCKET_DEV_INTERFACE PPB_WEBSOCKET_DEV_INTERFACE_0_9
21 22
22 /** 23 /**
23 * @file 24 * @file
24 * This file defines the <code>PPB_WebSocket_Dev</code> interface. 25 * This file defines the <code>PPB_WebSocket_Dev</code> interface.
25 */ 26 */
26 27
27 28
28 /** 29 /**
29 * @addtogroup Enums 30 * @addtogroup Enums
30 * @{ 31 * @{
(...skipping 22 matching lines...) Expand all
53 */ 54 */
54 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, 55 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2,
55 /** 56 /**
56 * Ready state that the connection has been closed or could not be opened. 57 * Ready state that the connection has been closed or could not be opened.
57 */ 58 */
58 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 59 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3
59 } PP_WebSocketReadyState_Dev; 60 } PP_WebSocketReadyState_Dev;
60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); 61 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4);
61 62
62 /** 63 /**
63 * This enumeration contains the types representing the WebSocket message type 64 * This enumeration contains the types representing the WebSocket binary type
64 * and these types are based on the JavaScript WebSocket API specification. 65 * to receive frames. These types are based on the JavaScript WebSocket API
65 * ReceiveMessage() and SendMessage() use them as a parameter to represent 66 * specification.
66 * handling message types.
67 */ 67 */
68 typedef enum { 68 typedef enum {
69 /** 69 /**
70 * Message type that represents a text message type. 70 * Binary type is queried on an invalid resource.
71 */ 71 */
72 PP_WEBSOCKET_MESSAGE_TYPE_TEXT_DEV = 0, 72 PP_WEBSOCKETBINARYTYPE_INVALID = -1,
73 /** 73 /**
74 * Message type that represents a binary message type. 74 * Binary type that represents Blob objects.
75 */ 75 */
76 PP_WEBSOCKET_MESSAGE_TYPE_BINARY_DEV = 1 76 PP_WEBSOCKETBINARYTYPE_BLOB_DEV = 0,
77 } PP_WebSocketMessageType_Dev; 77 /**
78 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketMessageType_Dev, 4); 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);
79 /** 83 /**
80 * @} 84 * @}
81 */ 85 */
82 86
83 /** 87 /**
84 * @addtogroup Interfaces 88 * @addtogroup Interfaces
85 * @{ 89 * @{
86 */ 90 */
87 struct PPB_WebSocket_Dev_0_1 { 91 struct PPB_WebSocket_Dev_0_9 {
88 /** 92 /**
89 * Create() creates a WebSocket instance. 93 * Create() creates a WebSocket instance.
90 * 94 *
91 * @param[in] instance A <code>PP_Instance</code> identifying the instance 95 * @param[in] instance A <code>PP_Instance</code> identifying the instance
92 * with the WebSocket. 96 * with the WebSocket.
93 * 97 *
94 * @return A <code>PP_Resource</code> corresponding to a WebSocket if 98 * @return A <code>PP_Resource</code> corresponding to a WebSocket if
95 * successful. 99 * successful.
96 */ 100 */
97 PP_Resource (*Create)(PP_Instance instance); 101 PP_Resource (*Create)(PP_Instance instance);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * GetURL() returns the URL associated with specified WebSocket connection. 318 * GetURL() returns the URL associated with specified WebSocket connection.
315 * 319 *
316 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a 320 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
317 * WebSocket. 321 * WebSocket.
318 * 322 *
319 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the 323 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
320 * connection is established, it contains the empty string. Return a 324 * connection is established, it contains the empty string. Return a
321 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource. 325 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
322 */ 326 */
323 struct PP_Var (*GetURL)(PP_Resource web_socket); 327 struct PP_Var (*GetURL)(PP_Resource web_socket);
328 /**
329 * SetBinaryType() specifies binary object type for receiving binary frames
330 * 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 specified binary object type.
334 * Default type must be <code>PP_WEBSOCKETBINARYTYPE_BLOB_DEV</code>, but
335 * currently is <code>PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER</code> for lack
336 * of Blob bindings for Pepper.
337 *
338 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
339 * WebSocket.
340 *
341 * @param[in] binary_type Binary object type for receibing binary frames
342 * representation.
343 *
344 * @return Returns <code>PP_FALSE</code> if specified type is not supported.
345 * Otherwise, returns <code>PP_TRUE</code>.
346 */
347 PP_Bool (*SetBinaryType)(PP_Resource web_socket,
348 PP_WebSocketBinaryType_Dev binary_type);
349 /**
350 * GetBinaryType() returns currently specified binary object type for
351 * receiving binary frames representation.
352 *
353 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
354 * WebSocket.
355 *
356 * @return Returns <code>PP_WebSocketBinaryType_Dev</code> represents
357 * current binary object type.
358 */
359 PP_WebSocketBinaryType_Dev (*GetBinaryType)(PP_Resource web_socket);
324 }; 360 };
325 361
326 typedef struct PPB_WebSocket_Dev_0_1 PPB_WebSocket_Dev; 362 typedef struct PPB_WebSocket_Dev_0_9 PPB_WebSocket_Dev;
363
364 struct PPB_WebSocket_Dev_0_1 {
365 PP_Resource (*Create)(PP_Instance instance);
366 PP_Bool (*IsWebSocket)(PP_Resource resource);
367 int32_t (*Connect)(PP_Resource web_socket,
368 struct PP_Var url,
369 const struct PP_Var protocols[],
370 uint32_t protocol_count,
371 struct PP_CompletionCallback callback);
372 int32_t (*Close)(PP_Resource web_socket,
373 uint16_t code,
374 struct PP_Var reason,
375 struct PP_CompletionCallback callback);
376 int32_t (*ReceiveMessage)(PP_Resource web_socket,
377 struct PP_Var* message,
378 struct PP_CompletionCallback callback);
379 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message);
380 uint64_t (*GetBufferedAmount)(PP_Resource web_socket);
381 uint16_t (*GetCloseCode)(PP_Resource web_socket);
382 struct PP_Var (*GetCloseReason)(PP_Resource web_socket);
383 PP_Bool (*GetCloseWasClean)(PP_Resource web_socket);
384 struct PP_Var (*GetExtensions)(PP_Resource web_socket);
385 struct PP_Var (*GetProtocol)(PP_Resource web_socket);
386 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket);
387 struct PP_Var (*GetURL)(PP_Resource web_socket);
388 };
327 /** 389 /**
328 * @} 390 * @}
329 */ 391 */
330 392
331 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ 393 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */
332 394
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698