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 Wed Jun 12 12:17:58 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 it will 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 it will conform to it. */ |
| 51 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 |
| 52 } PP_UDPSocket_Option_Dev; |
| 53 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option_Dev, 4); |
| 54 /** |
| 55 * @} |
| 56 */ |
| 57 |
| 58 /** |
| 59 * @addtogroup Interfaces |
| 60 * @{ |
| 61 */ |
| 62 struct PPB_UDPSocket_Dev_0_1 { |
| 63 /** |
| 64 * Creates a UDP socket resource. |
| 65 */ |
| 66 PP_Resource (*Create)(PP_Instance instance); |
| 67 /** |
| 68 * Determines if a given resource is a UDP socket. |
| 69 */ |
| 70 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
| 71 /** |
| 72 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev |
| 73 * resource. |
| 74 */ |
| 75 int32_t (*Bind)(PP_Resource udp_socket, |
| 76 PP_Resource addr, |
| 77 struct PP_CompletionCallback callback); |
| 78 /** |
| 79 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev |
| 80 * resource. A successful call to Bind must be called first. Returns 0 if |
| 81 * Bind fails, or if Close has been called. |
| 82 */ |
| 83 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
| 84 /** |
| 85 * Performs a non-blocking recvfrom call on socket. |
| 86 * Bind must be called first. |callback| is invoked when recvfrom reads data. |
| 87 * |addr| will store a PPB_NetAddress_Dev resource on success. |
| 88 */ |
| 89 int32_t (*RecvFrom)(PP_Resource udp_socket, |
| 90 char* buffer, |
| 91 int32_t num_bytes, |
| 92 PP_Resource* addr, |
| 93 struct PP_CompletionCallback callback); |
| 94 /** |
| 95 * Performs a non-blocking sendto call on the socket. |
| 96 * Bind must be called first. |addr| is a PPB_NetAddress_Dev resource holding |
| 97 * the target address. |callback| is invoked when sendto completes. |
| 98 */ |
| 99 int32_t (*SendTo)(PP_Resource udp_socket, |
| 100 const char* buffer, |
| 101 int32_t num_bytes, |
| 102 PP_Resource addr, |
| 103 struct PP_CompletionCallback callback); |
| 104 /** |
| 105 * Cancels all pending reads and writes, and closes the socket. |
| 106 */ |
| 107 void (*Close)(PP_Resource udp_socket); |
| 108 /** |
| 109 * Sets a socket option to |udp_socket|. Should be called before Bind(). |
| 110 * See the PP_UDPSocket_Option_Dev description for option names, value types |
| 111 * and allowed values. |
| 112 * Returns PP_OK on success. Otherwise, returns PP_ERROR_BADRESOURCE (if bad |
| 113 * |udp_socket| provided), PP_ERROR_BADARGUMENT (if bad name/value/value's |
| 114 * type provided) or PP_ERROR_FAILED in the case of internal errors. |
| 115 */ |
| 116 int32_t (*SetOption)(PP_Resource udp_socket, |
| 117 PP_UDPSocket_Option_Dev name, |
| 118 struct PP_Var value, |
| 119 struct PP_CompletionCallback callback); |
| 120 }; |
| 121 |
| 122 typedef struct PPB_UDPSocket_Dev_0_1 PPB_UDPSocket_Dev; |
| 123 /** |
| 124 * @} |
| 125 */ |
| 126 |
| 127 #endif /* PPAPI_C_DEV_PPB_UDP_SOCKET_DEV_H_ */ |
| 128 |
OLD | NEW |