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 Mon Jun 10 14:14:13 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 * TODO(yzshen): Tidy up the document. |
| 26 */ |
| 27 |
| 28 |
| 29 /** |
| 30 * @addtogroup Enums |
| 31 * @{ |
| 32 */ |
| 33 typedef enum { |
| 34 /* Allows the socket to share the local address to which it will be bound with |
| 35 * other processes. Value's type should be PP_VARTYPE_BOOL. */ |
| 36 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, |
| 37 /* Allows sending and receiving packets to and from broadcast addresses. |
| 38 * Value's type should be PP_VARTYPE_BOOL. */ |
| 39 PP_UDPSOCKET_OPTION_BROADCAST = 1, |
| 40 /* Specifies the total per-socket buffer space reserved for sends. Value's |
| 41 * type should be PP_VARTYPE_INT32. |
| 42 * Note: This is only treated as a hint for the browser to set the buffer |
| 43 * size. Even if SetOption() reports that this option has been successfully |
| 44 * set, the browser doesn't guarantee to conform to it. */ |
| 45 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, |
| 46 /* Specifies the total per-socket buffer space reserved for receives. Value's |
| 47 * type should be PP_VARTYPE_INT32. |
| 48 * Note: This is only treated as a hint for the browser to set the buffer |
| 49 * size. Even if SetOption() reports that this option has been successfully |
| 50 * set, the browser doesn't guarantee to conform to it. */ |
| 51 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, |
| 52 /* Specifies the receiving timeout. Value's type should be PP_VARTYPE_DOUBLE |
| 53 * which is in seconds. 0 (the default value) means the operation will never |
| 54 * timeout. */ |
| 55 PP_UDPSOCKET_OPTION_RECV_TIMEOUT = 4 |
| 56 } PP_UDPSocket_Option_Dev; |
| 57 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option_Dev, 4); |
| 58 /** |
| 59 * @} |
| 60 */ |
| 61 |
| 62 /** |
| 63 * @addtogroup Interfaces |
| 64 * @{ |
| 65 */ |
| 66 struct PPB_UDPSocket_Dev_0_1 { |
| 67 /** |
| 68 * Creates a UDP socket resource. |
| 69 */ |
| 70 PP_Resource (*Create)(PP_Instance instance); |
| 71 /** |
| 72 * Determines if a given resource is a UDP socket. |
| 73 */ |
| 74 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
| 75 /** |
| 76 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev |
| 77 * resource. |
| 78 */ |
| 79 int32_t (*Bind)(PP_Resource udp_socket, |
| 80 PP_Resource addr, |
| 81 struct PP_CompletionCallback callback); |
| 82 /** |
| 83 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev |
| 84 * resource. A successful call to Bind must be called first. Returns 0 if |
| 85 * Bind fails, or if Close has been called. |
| 86 */ |
| 87 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
| 88 /** |
| 89 * Performs a non-blocking recvfrom call on socket. |
| 90 * Bind must be called first. |callback| is invoked when recvfrom reads data. |
| 91 * |addr| will store a PPB_NetAddress_Dev resource on success. |
| 92 */ |
| 93 int32_t (*RecvFrom)(PP_Resource udp_socket, |
| 94 char* buffer, |
| 95 int32_t num_bytes, |
| 96 PP_Resource* addr, |
| 97 struct PP_CompletionCallback callback); |
| 98 /** |
| 99 * Performs a non-blocking sendto call on the socket created and bound (has |
| 100 * already called Bind). |addr| is a PPB_NetAddress_Dev resource indicating |
| 101 * the target address. The callback |callback| is invoked when sendto |
| 102 * completes. |
| 103 */ |
| 104 int32_t (*SendTo)(PP_Resource udp_socket, |
| 105 const char* buffer, |
| 106 int32_t num_bytes, |
| 107 PP_Resource addr, |
| 108 struct PP_CompletionCallback callback); |
| 109 /** |
| 110 * Cancels all pending reads and writes, and closes the socket. |
| 111 */ |
| 112 void (*Close)(PP_Resource udp_socket); |
| 113 /** |
| 114 * Sets a socket option to |udp_socket|. Should be called before Bind(). |
| 115 * Possible values for |name|, |value| and |value|'s type are described in |
| 116 * PP_UDPSocketOption_Dev description. If no error occurs, returns PP_OK. |
| 117 * Otherwise, returns PP_ERROR_BADRESOURCE (if bad |udp_socket| provided), |
| 118 * PP_ERROR_BADARGUMENT (if bad name/value/value's type provided) or |
| 119 * PP_ERROR_FAILED in the case of internal errors. |
| 120 */ |
| 121 int32_t (*SetOption)(PP_Resource udp_socket, |
| 122 PP_UDPSocket_Option_Dev name, |
| 123 struct PP_Var value, |
| 124 struct PP_CompletionCallback callback); |
| 125 }; |
| 126 |
| 127 typedef struct PPB_UDPSocket_Dev_0_1 PPB_UDPSocket_Dev; |
| 128 /** |
| 129 * @} |
| 130 */ |
| 131 |
| 132 #endif /* PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ */ |
| 133 |
OLD | NEW |