Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: libraries/nacl-mounts/ppapi/c/private/ppb_tcp_socket_private.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2012 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 private/ppb_tcp_socket_private.idl modified Wed Nov 16 15:27:20 2011. */
7
8 #ifndef PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_
9 #define PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_
10
11 #include "ppapi/c/private/ppb_net_address_private.h"
12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_macros.h"
16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_stdint.h"
18
19 #define PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3 "PPB_TCPSocket_Private;0.3"
20 #define PPB_TCPSOCKET_PRIVATE_INTERFACE PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3
21
22 /**
23 * @file
24 * This file defines the <code>PPB_TCPSocket_Private</code> interface.
25 */
26
27
28 /**
29 * @addtogroup Interfaces
30 * @{
31 */
32 /**
33 * The <code>PPB_TCPSocket_Private</code> interface provides TCP socket
34 * operations.
35 */
36 struct PPB_TCPSocket_Private_0_3 {
37 /**
38 * Allocates a TCP socket resource.
39 */
40 PP_Resource (*Create)(PP_Instance instance);
41 /**
42 * Determines if a given resource is TCP socket.
43 */
44 PP_Bool (*IsTCPSocket)(PP_Resource resource);
45 /**
46 * Connects to a TCP port given as a host-port pair.
47 * When a proxy server is used, |host| and |port| refer to the proxy server
48 * instead of the destination server.
49 */
50 int32_t (*Connect)(PP_Resource tcp_socket,
51 const char* host,
52 uint16_t port,
53 struct PP_CompletionCallback callback);
54 /**
55 * Same as Connect(), but connecting to the address given by |addr|. A typical
56 * use-case would be for reconnections.
57 */
58 int32_t (*ConnectWithNetAddress)(PP_Resource tcp_socket,
59 const struct PP_NetAddress_Private* addr,
60 struct PP_CompletionCallback callback);
61 /**
62 * Gets the local address of the socket, if it has been connected.
63 * Returns PP_TRUE on success.
64 */
65 PP_Bool (*GetLocalAddress)(PP_Resource tcp_socket,
66 struct PP_NetAddress_Private* local_addr);
67 /**
68 * Gets the remote address of the socket, if it has been connected.
69 * Returns PP_TRUE on success.
70 */
71 PP_Bool (*GetRemoteAddress)(PP_Resource tcp_socket,
72 struct PP_NetAddress_Private* remote_addr);
73 /**
74 * Does SSL handshake and moves to sending and receiving encrypted data. The
75 * socket must have been successfully connected. |server_name| will be
76 * compared with the name(s) in the server's certificate during the SSL
77 * handshake. |server_port| is only used to identify an SSL server in the SSL
78 * session cache.
79 * When a proxy server is used, |server_name| and |server_port| refer to the
80 * destination server.
81 * If the socket is not connected, or there are pending read/write requests,
82 * SSLHandshake() will fail without starting a handshake. Otherwise, any
83 * failure during the handshake process will cause the socket to be
84 * disconnected.
85 */
86 int32_t (*SSLHandshake)(PP_Resource tcp_socket,
87 const char* server_name,
88 uint16_t server_port,
89 struct PP_CompletionCallback callback);
90 /**
91 * Reads data from the socket. The size of |buffer| must be at least as large
92 * as |bytes_to_read|. May perform a partial read. Returns the number of bytes
93 * read or an error code. If the return value is 0, then it indicates that
94 * end-of-file was reached.
95 * This method won't return more than 1 megabyte, so if |bytes_to_read|
96 * exceeds 1 megabyte, it will always perform a partial read.
97 * Multiple outstanding read requests are not supported.
98 */
99 int32_t (*Read)(PP_Resource tcp_socket,
100 char* buffer,
101 int32_t bytes_to_read,
102 struct PP_CompletionCallback callback);
103 /**
104 * Writes data to the socket. May perform a partial write. Returns the number
105 * of bytes written or an error code.
106 * This method won't write more than 1 megabyte, so if |bytes_to_write|
107 * exceeds 1 megabyte, it will always perform a partial write.
108 * Multiple outstanding write requests are not supported.
109 */
110 int32_t (*Write)(PP_Resource tcp_socket,
111 const char* buffer,
112 int32_t bytes_to_write,
113 struct PP_CompletionCallback callback);
114 /**
115 * Cancels any IO that may be pending, and disconnects the socket. Any pending
116 * callbacks will still run, reporting PP_Error_Aborted if pending IO was
117 * interrupted. It is NOT valid to call Connect() again after a call to this
118 * method. Note: If the socket is destroyed when it is still connected, then
119 * it will be implicitly disconnected, so you are not required to call this
120 * method.
121 */
122 void (*Disconnect)(PP_Resource tcp_socket);
123 };
124
125 typedef struct PPB_TCPSocket_Private_0_3 PPB_TCPSocket_Private;
126 /**
127 * @}
128 */
129
130 #endif /* PPAPI_C_PRIVATE_PPB_TCP_SOCKET_PRIVATE_H_ */
131
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698