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 /** |
| 7 * This file defines the <code>PPB_UDPSocket_Dev</code> interface. |
| 8 * TODO(yzshen): Tidy up the document. |
| 9 */ |
| 10 |
| 11 [generate_thunk] |
| 12 |
| 13 label Chrome { |
| 14 M29 = 0.1 |
| 15 }; |
| 16 |
| 17 [assert_size(4)] |
| 18 enum PP_UDPSocket_Option_Dev { |
| 19 // Allows the socket to share the local address to which it will be bound with |
| 20 // other processes. Value's type should be PP_VARTYPE_BOOL. |
| 21 PP_UDPSOCKET_OPTION_ADDRESS_REUSE = 0, |
| 22 |
| 23 // Allows sending and receiving packets to and from broadcast addresses. |
| 24 // Value's type should be PP_VARTYPE_BOOL. |
| 25 PP_UDPSOCKET_OPTION_BROADCAST = 1, |
| 26 |
| 27 // Specifies the total per-socket buffer space reserved for sends. Value's |
| 28 // type should be PP_VARTYPE_INT32. |
| 29 // Note: This is only treated as a hint for the browser to set the buffer |
| 30 // size. Even if SetOption() reports that this option has been successfully |
| 31 // set, the browser doesn't guarantee it will conform to it. |
| 32 PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE = 2, |
| 33 |
| 34 // Specifies the total per-socket buffer space reserved for receives. Value's |
| 35 // type should be PP_VARTYPE_INT32. |
| 36 // Note: This is only treated as a hint for the browser to set the buffer |
| 37 // size. Even if SetOption() reports that this option has been successfully |
| 38 // set, the browser doesn't guarantee it will conform to it. |
| 39 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3 |
| 40 }; |
| 41 |
| 42 interface PPB_UDPSocket_Dev { |
| 43 /** |
| 44 * Creates a UDP socket resource. |
| 45 */ |
| 46 PP_Resource Create([in] PP_Instance instance); |
| 47 |
| 48 /** |
| 49 * Determines if a given resource is a UDP socket. |
| 50 */ |
| 51 PP_Bool IsUDPSocket([in] PP_Resource resource); |
| 52 |
| 53 /** |
| 54 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev |
| 55 * resource. |
| 56 */ |
| 57 int32_t Bind([in] PP_Resource udp_socket, |
| 58 [in] PP_Resource addr, |
| 59 [in] PP_CompletionCallback callback); |
| 60 |
| 61 /** |
| 62 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev |
| 63 * resource. Bind must be called and succeed first. Returns 0 if Bind fails, |
| 64 * or if Close has been called. |
| 65 */ |
| 66 PP_Resource GetBoundAddress([in] PP_Resource udp_socket); |
| 67 |
| 68 /** |
| 69 * Performs a non-blocking recvfrom call on socket. |
| 70 * Bind must be called first. |callback| is invoked when recvfrom reads data. |
| 71 * |addr| will store a PPB_NetAddress_Dev resource on success. |
| 72 */ |
| 73 int32_t RecvFrom([in] PP_Resource udp_socket, |
| 74 [out] str_t buffer, |
| 75 [in] int32_t num_bytes, |
| 76 [out] PP_Resource addr, |
| 77 [in] PP_CompletionCallback callback); |
| 78 |
| 79 /** |
| 80 * Performs a non-blocking sendto call on the socket. |
| 81 * Bind must be called first. |addr| is a PPB_NetAddress_Dev resource holding |
| 82 * the target address. |callback| is invoked when sendto completes. |
| 83 */ |
| 84 int32_t SendTo([in] PP_Resource udp_socket, |
| 85 [in] str_t buffer, |
| 86 [in] int32_t num_bytes, |
| 87 [in] PP_Resource addr, |
| 88 [in] PP_CompletionCallback callback); |
| 89 |
| 90 /** |
| 91 * Cancels all pending reads and writes, and closes the socket. |
| 92 */ |
| 93 void Close([in] PP_Resource udp_socket); |
| 94 |
| 95 /** |
| 96 * Sets a socket option to |udp_socket|. Should be called before Bind(). |
| 97 * See the PP_UDPSocket_Option_Dev description for option names, value types |
| 98 * and allowed values. |
| 99 * Returns PP_OK on success. Otherwise, returns PP_ERROR_BADRESOURCE (if bad |
| 100 * |udp_socket| provided), PP_ERROR_BADARGUMENT (if bad name/value/value's |
| 101 * type provided) or PP_ERROR_FAILED in the case of internal errors. |
| 102 */ |
| 103 int32_t SetOption([in] PP_Resource udp_socket, |
| 104 [in] PP_UDPSocket_Option_Dev name, |
| 105 [in] PP_Var value, |
| 106 [in] PP_CompletionCallback callback); |
| 107 }; |
OLD | NEW |