OLD | NEW |
1 /* Copyright 2013 The Chromium Authors. All rights reserved. | 1 /* Copyright 2013 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 ppb_udp_socket.idl modified Sat Jun 22 10:56:26 2013. */ | 6 /* From ppb_udp_socket.idl modified Wed Dec 10 04:11:03 2014. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ | 8 #ifndef PPAPI_C_PPB_UDP_SOCKET_H_ |
9 #define PPAPI_C_PPB_UDP_SOCKET_H_ | 9 #define PPAPI_C_PPB_UDP_SOCKET_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_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" | 19 #define PPB_UDPSOCKET_INTERFACE_1_0 "PPB_UDPSocket;1.0" |
20 #define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_0 | 20 #define PPB_UDPSOCKET_INTERFACE_1_1 "PPB_UDPSocket;1.1" |
| 21 #define PPB_UDPSOCKET_INTERFACE PPB_UDPSOCKET_INTERFACE_1_1 |
21 | 22 |
22 /** | 23 /** |
23 * @file | 24 * @file |
24 * This file defines the <code>PPB_UDPSocket</code> interface. | 25 * This file defines the <code>PPB_UDPSocket</code> interface. |
25 */ | 26 */ |
26 | 27 |
27 | 28 |
28 /** | 29 /** |
29 * @addtogroup Enums | 30 * @addtogroup Enums |
30 * @{ | 31 * @{ |
31 */ | 32 */ |
32 /** | 33 /** |
33 * Option names used by <code>SetOption()</code>. | 34 * Option names used by <code>SetOption()</code>. |
34 */ | 35 */ |
35 typedef enum { | 36 typedef enum { |
36 /** | 37 /** |
37 * Allows the socket to share the local address to which it will be bound with | 38 * Allows the socket to share the local address to which it will be bound with |
38 * other processes. Value's type should be <code>PP_VARTYPE_BOOL</code>. | 39 * other processes. Value's type should be <code>PP_VARTYPE_BOOL</code>. |
39 * This option can only be set before calling <code>Bind()</code>. | 40 * This option can only be set before calling <code>Bind()</code>. |
40 */ | 41 */ |
41 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, | 42 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, |
42 /** | 43 /** |
43 * Allows sending and receiving packets to and from broadcast addresses. | 44 * Allows sending and receiving packets to and from broadcast addresses. |
44 * Value's type should be <code>PP_VARTYPE_BOOL</code>. | 45 * Value's type should be <code>PP_VARTYPE_BOOL</code>. |
45 * This option can only be set before calling <code>Bind()</code>. | 46 * On version 1.0, this option can only be set before calling |
| 47 * <code>Bind()</code>. On version 1.1 or later, there is no such limitation. |
46 */ | 48 */ |
47 PP_UDPSOCKET_OPTION_BROADCAST = 1, | 49 PP_UDPSOCKET_OPTION_BROADCAST = 1, |
48 /** | 50 /** |
49 * Specifies the total per-socket buffer space reserved for sends. Value's | 51 * Specifies the total per-socket buffer space reserved for sends. Value's |
50 * type should be <code>PP_VARTYPE_INT32</code>. | 52 * type should be <code>PP_VARTYPE_INT32</code>. |
51 * This option can only be set after a successful <code>Bind()</code> call. | 53 * On version 1.0, this option can only be set after a successful |
| 54 * <code>Bind()</code> call. On version 1.1 or later, there is no such |
| 55 * limitation. |
52 * | 56 * |
53 * Note: This is only treated as a hint for the browser to set the buffer | 57 * Note: This is only treated as a hint for the browser to set the buffer |
54 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't | 58 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't |
55 * guarantee it will conform to the size. | 59 * guarantee it will conform to the size. |
56 */ | 60 */ |
57 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, | 61 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, |
58 /** | 62 /** |
59 * Specifies the total per-socket buffer space reserved for receives. Value's | 63 * Specifies the total per-socket buffer space reserved for receives. Value's |
60 * type should be <code>PP_VARTYPE_INT32</code>. | 64 * type should be <code>PP_VARTYPE_INT32</code>. |
61 * This option can only be set after a successful <code>Bind()</code> call. | 65 * On version 1.0, this option can only be set after a successful |
| 66 * <code>Bind()</code> call. On version 1.1 or later, there is no such |
| 67 * limitation. |
62 * | 68 * |
63 * Note: This is only treated as a hint for the browser to set the buffer | 69 * Note: This is only treated as a hint for the browser to set the buffer |
64 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't | 70 * size. Even if <code>SetOption()</code> succeeds, the browser doesn't |
65 * guarantee it will conform to the size. | 71 * guarantee it will conform to the size. |
66 */ | 72 */ |
67 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 | 73 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 |
68 } PP_UDPSocket_Option; | 74 } PP_UDPSocket_Option; |
69 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); | 75 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_UDPSocket_Option, 4); |
70 /** | 76 /** |
71 * @} | 77 * @} |
72 */ | 78 */ |
73 | 79 |
74 /** | 80 /** |
75 * @addtogroup Interfaces | 81 * @addtogroup Interfaces |
76 * @{ | 82 * @{ |
77 */ | 83 */ |
78 /** | 84 /** |
79 * The <code>PPB_UDPSocket</code> interface provides UDP socket operations. | 85 * The <code>PPB_UDPSocket</code> interface provides UDP socket operations. |
80 * | 86 * |
81 * Permissions: Apps permission <code>socket</code> with subrule | 87 * Permissions: Apps permission <code>socket</code> with subrule |
82 * <code>udp-bind</code> is required for <code>Bind()</code>; subrule | 88 * <code>udp-bind</code> is required for <code>Bind()</code>; subrule |
83 * <code>udp-send-to</code> is required for <code>SendTo()</code>. | 89 * <code>udp-send-to</code> is required for <code>SendTo()</code>. |
84 * For more details about network communication permissions, please see: | 90 * For more details about network communication permissions, please see: |
85 * http://developer.chrome.com/apps/app_network.html | 91 * http://developer.chrome.com/apps/app_network.html |
86 */ | 92 */ |
87 struct PPB_UDPSocket_1_0 { | 93 struct PPB_UDPSocket_1_1 { |
88 /** | 94 /** |
89 * Creates a UDP socket resource. | 95 * Creates a UDP socket resource. |
90 * | 96 * |
91 * @param[in] instance A <code>PP_Instance</code> identifying one instance of | 97 * @param[in] instance A <code>PP_Instance</code> identifying one instance of |
92 * a module. | 98 * a module. |
93 * | 99 * |
94 * @return A <code>PP_Resource</code> corresponding to a UDP socket or 0 | 100 * @return A <code>PP_Resource</code> corresponding to a UDP socket or 0 |
95 * on failure. | 101 * on failure. |
96 */ | 102 */ |
97 PP_Resource (*Create)(PP_Instance instance); | 103 PP_Resource (*Create)(PP_Instance instance); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 * completion. | 207 * completion. |
202 * | 208 * |
203 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 209 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
204 */ | 210 */ |
205 int32_t (*SetOption)(PP_Resource udp_socket, | 211 int32_t (*SetOption)(PP_Resource udp_socket, |
206 PP_UDPSocket_Option name, | 212 PP_UDPSocket_Option name, |
207 struct PP_Var value, | 213 struct PP_Var value, |
208 struct PP_CompletionCallback callback); | 214 struct PP_CompletionCallback callback); |
209 }; | 215 }; |
210 | 216 |
211 typedef struct PPB_UDPSocket_1_0 PPB_UDPSocket; | 217 typedef struct PPB_UDPSocket_1_1 PPB_UDPSocket; |
| 218 |
| 219 struct PPB_UDPSocket_1_0 { |
| 220 PP_Resource (*Create)(PP_Instance instance); |
| 221 PP_Bool (*IsUDPSocket)(PP_Resource resource); |
| 222 int32_t (*Bind)(PP_Resource udp_socket, |
| 223 PP_Resource addr, |
| 224 struct PP_CompletionCallback callback); |
| 225 PP_Resource (*GetBoundAddress)(PP_Resource udp_socket); |
| 226 int32_t (*RecvFrom)(PP_Resource udp_socket, |
| 227 char* buffer, |
| 228 int32_t num_bytes, |
| 229 PP_Resource* addr, |
| 230 struct PP_CompletionCallback callback); |
| 231 int32_t (*SendTo)(PP_Resource udp_socket, |
| 232 const char* buffer, |
| 233 int32_t num_bytes, |
| 234 PP_Resource addr, |
| 235 struct PP_CompletionCallback callback); |
| 236 void (*Close)(PP_Resource udp_socket); |
| 237 int32_t (*SetOption)(PP_Resource udp_socket, |
| 238 PP_UDPSocket_Option name, |
| 239 struct PP_Var value, |
| 240 struct PP_CompletionCallback callback); |
| 241 }; |
212 /** | 242 /** |
213 * @} | 243 * @} |
214 */ | 244 */ |
215 | 245 |
216 #endif /* PPAPI_C_PPB_UDP_SOCKET_H_ */ | 246 #endif /* PPAPI_C_PPB_UDP_SOCKET_H_ */ |
217 | 247 |
OLD | NEW |