OLD | NEW |
(Empty) | |
| 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 |
| 6 /* From dev/ppb_udp_socket_dev.idl modified Fri Jun 07 14:22:41 2013. */ |
| 7 |
| 8 #ifndef PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ |
| 9 #define PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ |
| 10 |
| 11 #include "ppapi/c/pp_bool.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/c/pp_macros.h" |
| 15 #include "ppapi/c/pp_resource.h" |
| 16 #include "ppapi/c/pp_stdint.h" |
| 17 #include "ppapi/c/pp_var.h" |
| 18 |
| 19 #define PPB_UDPSOCKET_DEV_INTERFACE_0_1 "PPB_UDPSocket(Dev);0.1" |
| 20 #define PPB_UDPSOCKET_DEV_INTERFACE PPB_UDPSOCKET_DEV_INTERFACE_0_1 |
| 21 |
| 22 /** |
| 23 * @file |
| 24 * This file defines the <code>PPB_UDPSocket_Dev</code> interface. |
| 25 */ |
| 26 |
| 27 |
| 28 /** |
| 29 * @addtogroup Enums |
| 30 * @{ |
| 31 */ |
| 32 typedef enum { |
| 33 /* Allows the socket to share the local address to which socket will |
| 34 * be bound with other processes. Value's type should be PP_VARTYPE_BOOL. */ |
| 35 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, |
| 36 /* Allows sending and receiving packets sent to and from broadcast addresses. |
| 37 * Value's type should be PP_VARTYPE_BOOL. */ |
| 38 PP_UDPSOCKET_OPTION_BROADCAST = 1, |
| 39 /* Specifies the total per-socket buffer space reserved for sends. Value's |
| 40 * type should be PP_VARTYPE_INT32. |
| 41 * Note: This is only treated as a hint for the browser to set the buffer |
| 42 * size. Even if SetOption() reports that this option has been successfully |
| 43 * set, the browser doesn't guarantee to conform to it. */ |
| 44 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, |
| 45 /* Specifies the total per-socket buffer space reserved for receives. Value's |
| 46 * type should be PP_VARTYPE_INT32. |
| 47 * Note: This is only treated as a hint for the browser to set the buffer |
| 48 * size. Even if SetOption() reports that this option has been successfully |
| 49 * set, the browser doesn't guarantee to conform to it. */ |
| 50 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, |
| 51 /* Specifies the receiving timeout. Value's type should be PP_VARTYPE_DOUBLE |
| 52 * which is in seconds. 0 (the default value) means the operation will never |
| 53 * timeout. */ |
| 54 PP_UDPSOCKET_OPTION_RECV_TIMEOUT = 4 |
| 55 } PP_UDPSocket_Option_Dev; |
| 56 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option_Dev, 4); |
| 57 /** |
| 58 * @} |
| 59 */ |
| 60 |
| 61 /** |
| 62 * @addtogroup Interfaces |
| 63 * @{ |
| 64 */ |
| 65 struct PPB_UDPSocket_Dev_0_1 { |
| 66 /** |
| 67 * Creates a UDP socket resource. |
| 68 */ |
| 69 PP_Resource (*Create)(PP_Instance instance); |
| 70 /** |
| 71 * Determines if a given resource is a UDP socket. |
| 72 */ |
| 73 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
| 74 /** |
| 75 * Binds to the address given by |addr|. |
| 76 */ |
| 77 int32_t (*Bind)(PP_Resource udp_socket, |
| 78 PP_Resource addr, |
| 79 struct PP_CompletionCallback callback); |
| 80 /** |
| 81 * Returns the address that the socket has bound to. A successful call to |
| 82 * Bind must be called first. Returns 0 if Bind fails, or if Close has |
| 83 * been called. |
| 84 */ |
| 85 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
| 86 /** |
| 87 * Performs a non-blocking recvfrom call on socket. |
| 88 * Bind must be called first. |callback| is invoked when recvfrom reads data. |
| 89 */ |
| 90 int32_t (*RecvFrom)(PP_Resource udp_socket, |
| 91 char* buffer, |
| 92 int32_t num_bytes, |
| 93 PP_Resource* addr, |
| 94 struct PP_CompletionCallback callback); |
| 95 /** |
| 96 * Performs a non-blocking sendto call on the socket created and bound (has |
| 97 * already called Bind). The callback |callback| is invoked when sendto |
| 98 * completes. |
| 99 */ |
| 100 int32_t (*SendTo)(PP_Resource udp_socket, |
| 101 const char* buffer, |
| 102 int32_t num_bytes, |
| 103 PP_Resource addr, |
| 104 struct PP_CompletionCallback callback); |
| 105 /** |
| 106 * Cancels all pending reads and writes, and closes the socket. |
| 107 */ |
| 108 void (*Close)(PP_Resource udp_socket); |
| 109 /** |
| 110 * Sets a socket option to |udp_socket|. Should be called before Bind(). |
| 111 * Possible values for |name|, |value| and |value|'s type are described in |
| 112 * PP_UDPSocketOption_Dev description. If no error occurs, returns PP_OK. |
| 113 * Otherwise, returns PP_ERROR_BADRESOURCE (if bad |udp_socket| provided), |
| 114 * PP_ERROR_BADARGUMENT (if bad name/value/value's type provided) or |
| 115 * PP_ERROR_FAILED in the case of internal errors. |
| 116 */ |
| 117 int32_t (*SetOption)(PP_Resource udp_socket, |
| 118 PP_UDPSocket_Option_Dev name, |
| 119 struct PP_Var value, |
| 120 struct PP_CompletionCallback callback); |
| 121 }; |
| 122 |
| 123 typedef struct PPB_UDPSocket_Dev_0_1 PPB_UDPSocket_Dev; |
| 124 /** |
| 125 * @} |
| 126 */ |
| 127 |
| 128 #endif /* PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ */ |
| 129 |
OLD | NEW |