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

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: fix reviewed points 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
« no previous file with comments | « ppapi/api/dev/ppb_websocket_dev.idl ('k') | ppapi/tests/test_websocket.cc » ('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 Mon Dec 19 19:44:12 2011. */ 6 /* From dev/ppb_websocket_dev.idl modified Wed Jan 11 14:21:33 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 the binary object type for receiving binary
330 * frames 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 the specified binary object type.
334 * Default type is <code>PP_WEBSOCKETBINARYTYPE_BLOB_DEV</code>.
335 *
336 * Currently, Blob bindings is not supported in Pepper, so receiving binary
337 * type is always ArrayBuffer. To ensure backward compatibility, you must
338 * call this function with
339 * <code>PP_WEBSOCKETBINARYTYPE_ARRAYBUFFER_DEV</code> to use binary frames.
340 *
341 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
342 * WebSocket.
343 *
344 * @param[in] binary_type Binary object type for receibing binary frames
345 * representation.
346 *
347 * @return Returns <code>PP_FALSE</code> if the specified type is not
348 * supported. Otherwise, returns <code>PP_TRUE</code>.
349 */
350 PP_Bool (*SetBinaryType)(PP_Resource web_socket,
351 PP_WebSocketBinaryType_Dev binary_type);
352 /**
353 * GetBinaryType() returns currently specified binary object type for
354 * receiving binary frames representation.
355 *
356 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
357 * WebSocket.
358 *
359 * @return Returns <code>PP_WebSocketBinaryType_Dev</code> represents
360 * current binary object type.
361 */
362 PP_WebSocketBinaryType_Dev (*GetBinaryType)(PP_Resource web_socket);
324 }; 363 };
325 364
326 typedef struct PPB_WebSocket_Dev_0_1 PPB_WebSocket_Dev; 365 typedef struct PPB_WebSocket_Dev_0_9 PPB_WebSocket_Dev;
366
367 struct PPB_WebSocket_Dev_0_1 {
368 PP_Resource (*Create)(PP_Instance instance);
369 PP_Bool (*IsWebSocket)(PP_Resource resource);
370 int32_t (*Connect)(PP_Resource web_socket,
371 struct PP_Var url,
372 const struct PP_Var protocols[],
373 uint32_t protocol_count,
374 struct PP_CompletionCallback callback);
375 int32_t (*Close)(PP_Resource web_socket,
376 uint16_t code,
377 struct PP_Var reason,
378 struct PP_CompletionCallback callback);
379 int32_t (*ReceiveMessage)(PP_Resource web_socket,
380 struct PP_Var* message,
381 struct PP_CompletionCallback callback);
382 int32_t (*SendMessage)(PP_Resource web_socket, struct PP_Var message);
383 uint64_t (*GetBufferedAmount)(PP_Resource web_socket);
384 uint16_t (*GetCloseCode)(PP_Resource web_socket);
385 struct PP_Var (*GetCloseReason)(PP_Resource web_socket);
386 PP_Bool (*GetCloseWasClean)(PP_Resource web_socket);
387 struct PP_Var (*GetExtensions)(PP_Resource web_socket);
388 struct PP_Var (*GetProtocol)(PP_Resource web_socket);
389 PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket);
390 struct PP_Var (*GetURL)(PP_Resource web_socket);
391 };
327 /** 392 /**
328 * @} 393 * @}
329 */ 394 */
330 395
331 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ 396 #endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */
332 397
OLDNEW
« no previous file with comments | « ppapi/api/dev/ppb_websocket_dev.idl ('k') | ppapi/tests/test_websocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698