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_TCPSocket_Dev</code> interface. |
| 8 */ |
| 9 |
| 10 [generate_thunk] |
| 11 |
| 12 label Chrome { |
| 13 M29 = 0.1 |
| 14 }; |
| 15 |
| 16 [assert_size(4)] |
| 17 enum PP_TCPSocket_Option_Dev { |
| 18 // Disables coalescing of small writes to make TCP segments, and instead |
| 19 // deliver data immediately. Value type is PP_VARTYPE_BOOL. |
| 20 PP_TCPSOCKET_OPTION_NO_DELAY = 0, |
| 21 |
| 22 // Specifies the socket send buffer in bytes. Value's type should be |
| 23 // PP_VARTYPE_INT32. |
| 24 // Note: This is only treated as a hint for the browser to set the buffer |
| 25 // size. Even if SetOption() reports that this option has been successfully |
| 26 // set, the browser doesn't guarantee to conform to it. |
| 27 PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE = 1, |
| 28 |
| 29 // Specifies the socket receive buffer in bytes. Value's type should be |
| 30 // PP_VARTYPE_INT32. |
| 31 // Note: This is only treated as a hint for the browser to set the buffer |
| 32 // size. Even if SetOption() reports that this option has been successfully |
| 33 // set, the browser doesn't guarantee to conform to it. |
| 34 PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE = 2 |
| 35 }; |
| 36 |
| 37 /** |
| 38 * The <code>PPB_TCPSocket_Dev</code> interface provides TCP socket operations. |
| 39 */ |
| 40 interface PPB_TCPSocket_Dev { |
| 41 /** |
| 42 * Allocates a TCP socket resource. |
| 43 */ |
| 44 PP_Resource Create([in] PP_Instance instance); |
| 45 |
| 46 /** |
| 47 * Determines if a given resource is TCP socket. |
| 48 */ |
| 49 PP_Bool IsTCPSocket([in] PP_Resource resource); |
| 50 |
| 51 /** |
| 52 * Connects to an address given by |addr|, which is a PPB_NetAddress_Dev |
| 53 * resource. |
| 54 */ |
| 55 int32_t Connect([in] PP_Resource tcp_socket, |
| 56 [in] PP_Resource addr, |
| 57 [in] PP_CompletionCallback callback); |
| 58 |
| 59 /** |
| 60 * Gets the local address of the socket, if it has been connected. |
| 61 * Returns a PPB_NetAddress_Dev resource on success; returns 0 on failure. |
| 62 */ |
| 63 PP_Resource GetLocalAddress([in] PP_Resource tcp_socket); |
| 64 |
| 65 /** |
| 66 * Gets the remote address of the socket, if it has been connected. |
| 67 * Returns a PPB_NetAddress_Dev resource on success; returns 0 on failure. |
| 68 */ |
| 69 PP_Resource GetRemoteAddress([in] PP_Resource tcp_socket); |
| 70 |
| 71 /** |
| 72 * Reads data from the socket. The size of |buffer| must be at least as large |
| 73 * as |bytes_to_read|. May perform a partial read. Returns the number of bytes |
| 74 * read or an error code. If the return value is 0, then it indicates that |
| 75 * end-of-file was reached. |
| 76 * |
| 77 * Multiple outstanding read requests are not supported. |
| 78 */ |
| 79 int32_t Read([in] PP_Resource tcp_socket, |
| 80 [out] str_t buffer, |
| 81 [in] int32_t bytes_to_read, |
| 82 [in] PP_CompletionCallback callback); |
| 83 |
| 84 /** |
| 85 * Writes data to the socket. May perform a partial write. Returns the number |
| 86 * of bytes written or an error code. |
| 87 * |
| 88 * Multiple outstanding write requests are not supported. |
| 89 */ |
| 90 int32_t Write([in] PP_Resource tcp_socket, |
| 91 [in] str_t buffer, |
| 92 [in] int32_t bytes_to_write, |
| 93 [in] PP_CompletionCallback callback); |
| 94 |
| 95 /** |
| 96 * Cancels any IO that may be pending, and disconnects the socket. Any pending |
| 97 * callbacks will still run, reporting PP_ERROR_ABORTED if pending IO was |
| 98 * interrupted. It is NOT valid to call Connect() again after a call to this |
| 99 * method. Note: If the socket is destroyed when it is still connected, then |
| 100 * it will be implicitly disconnected, so you are not required to call this |
| 101 * method. |
| 102 */ |
| 103 void Close([in] PP_Resource tcp_socket); |
| 104 |
| 105 /** |
| 106 * Sets an option on |tcp_socket|. Supported |name| and |value| parameters |
| 107 * are as described for PP_TCPSocketOption_Dev. |callback| will be |
| 108 * invoked with PP_OK if setting the option succeeds, or an error code |
| 109 * otherwise. The socket must be connected before SetOption is called. |
| 110 */ |
| 111 int32_t SetOption([in] PP_Resource tcp_socket, |
| 112 [in] PP_TCPSocket_Option_Dev name, |
| 113 [in] PP_Var value, |
| 114 [in] PP_CompletionCallback callback); |
| 115 }; |
OLD | NEW |