Chromium Code Reviews| 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 to conform to it. | |
|
bbudge
2013/06/12 18:52:37
s/guarantee to/guarantee it will/
Here and below.
yzshen1
2013/06/12 19:32:53
Done.
| |
| 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 to conform to it. | |
| 39 PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE = 3, | |
| 40 | |
| 41 // Specifies the receiving timeout. Value's type should be PP_VARTYPE_DOUBLE | |
| 42 // which is in seconds. 0 (the default value) means the operation will never | |
| 43 // timeout. | |
| 44 PP_UDPSOCKET_OPTION_RECV_TIMEOUT = 4 | |
|
bbudge
2013/06/12 18:52:37
Remove?
yzshen1
2013/06/12 19:32:53
Done.
| |
| 45 }; | |
| 46 | |
| 47 interface PPB_UDPSocket_Dev { | |
| 48 /** | |
| 49 * Creates a UDP socket resource. | |
| 50 */ | |
| 51 PP_Resource Create([in] PP_Instance instance); | |
| 52 | |
| 53 /** | |
| 54 * Determines if a given resource is a UDP socket. | |
| 55 */ | |
| 56 PP_Bool IsUDPSocket([in] PP_Resource resource); | |
| 57 | |
| 58 /** | |
| 59 * Binds to the address given by |addr|, which is a PPB_NetAddress_Dev | |
| 60 * resource. | |
| 61 */ | |
| 62 int32_t Bind([in] PP_Resource udp_socket, | |
| 63 [in] PP_Resource addr, | |
| 64 [in] PP_CompletionCallback callback); | |
| 65 | |
| 66 /** | |
| 67 * Returns the address that the socket has bound to, as a PPB_NetAddress_Dev | |
| 68 * resource. A successful call to Bind must be called first. Returns 0 if | |
| 69 * Bind fails, or if Close has been called. | |
| 70 */ | |
| 71 PP_Resource GetBoundAddress([in] PP_Resource udp_socket); | |
| 72 | |
| 73 /** | |
| 74 * Performs a non-blocking recvfrom call on socket. | |
| 75 * Bind must be called first. |callback| is invoked when recvfrom reads data. | |
| 76 * |addr| will store a PPB_NetAddress_Dev resource on success. | |
| 77 */ | |
| 78 int32_t RecvFrom([in] PP_Resource udp_socket, | |
| 79 [out] str_t buffer, | |
| 80 [in] int32_t num_bytes, | |
| 81 [out] PP_Resource addr, | |
| 82 [in] PP_CompletionCallback callback); | |
| 83 | |
| 84 /** | |
| 85 * Performs a non-blocking sendto call on the socket created and bound (has | |
| 86 * already called Bind). |addr| is a PPB_NetAddress_Dev resource indicating | |
|
bbudge
2013/06/12 18:52:37
A little awkward - why not use the wording from Re
yzshen1
2013/06/12 19:32:53
Done. Thanks!
On 2013/06/12 18:52:37, bbudge1 wrot
| |
| 87 * the target address. The callback |callback| is invoked when sendto | |
| 88 * completes. | |
| 89 */ | |
| 90 int32_t SendTo([in] PP_Resource udp_socket, | |
| 91 [in] str_t buffer, | |
| 92 [in] int32_t num_bytes, | |
| 93 [in] PP_Resource addr, | |
| 94 [in] PP_CompletionCallback callback); | |
| 95 | |
| 96 /** | |
| 97 * Cancels all pending reads and writes, and closes the socket. | |
| 98 */ | |
| 99 void Close([in] PP_Resource udp_socket); | |
| 100 | |
| 101 /** | |
| 102 * Sets a socket option to |udp_socket|. Should be called before Bind(). | |
| 103 * Possible values for |name|, |value| and |value|'s type are described in | |
|
bbudge
2013/06/12 18:52:37
Maybe this would be a little clearer:
* See the PP
yzshen1
2013/06/12 19:32:53
Done.
| |
| 104 * PP_UDPSocketOption_Dev description. If no error occurs, returns PP_OK. | |
|
bbudge
2013/06/12 18:52:37
s/If no error occurs, returns PP_OK/Returns PP_OK
yzshen1
2013/06/12 19:32:53
Thanks!
Sorry for bad comments. :) Some of them w
| |
| 105 * Otherwise, returns PP_ERROR_BADRESOURCE (if bad |udp_socket| provided), | |
| 106 * PP_ERROR_BADARGUMENT (if bad name/value/value's type provided) or | |
| 107 * PP_ERROR_FAILED in the case of internal errors. | |
| 108 */ | |
| 109 int32_t SetOption([in] PP_Resource udp_socket, | |
| 110 [in] PP_UDPSocket_Option_Dev name, | |
| 111 [in] PP_Var value, | |
| 112 [in] PP_CompletionCallback callback); | |
| 113 }; | |
| OLD | NEW |