- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / c / private / ppb_tcp_server_socket_private.h
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_server_socket_private.idl,
7  *   modified Mon May 20 12:45:38 2013.
8  */
9
10 #ifndef PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_
11 #define PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_
12
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_macros.h"
17 #include "ppapi/c/pp_resource.h"
18 #include "ppapi/c/pp_stdint.h"
19 #include "ppapi/c/private/ppb_net_address_private.h"
20
21 #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1 \
22     "PPB_TCPServerSocket_Private;0.1"
23 #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2 \
24     "PPB_TCPServerSocket_Private;0.2"
25 #define PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE \
26     PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2
27
28 /**
29  * @file
30  * This file defines the <code>PPB_TCPServerSocket_Private</code> interface.
31  */
32
33
34 /**
35  * @addtogroup Interfaces
36  * @{
37  */
38 /**
39  * The <code>PPB_TCPServerSocket_Private</code> interface provides TCP
40  * server socket operations.
41  */
42 struct PPB_TCPServerSocket_Private_0_2 {
43   /**
44    * Allocates a TCP server socket resource.
45    */
46   PP_Resource (*Create)(PP_Instance instance);
47   /**
48    * Determines if a given resource is TCP server socket.
49    */
50   PP_Bool (*IsTCPServerSocket)(PP_Resource resource);
51   /**
52    * Binds |tcp_server_socket| to the address given by |addr| and
53    * starts listening.  The |backlog| argument defines the maximum
54    * length to which the queue of pending connections may
55    * grow. |callback| is invoked when |tcp_server_socket| is ready to
56    * accept incoming connections or in the case of failure. Returns
57    * PP_ERROR_NOSPACE if socket can't be initialized, or
58    * PP_ERROR_FAILED in the case of Listen failure. Otherwise, returns
59    * PP_OK.
60    */
61   int32_t (*Listen)(PP_Resource tcp_server_socket,
62                     const struct PP_NetAddress_Private* addr,
63                     int32_t backlog,
64                     struct PP_CompletionCallback callback);
65   /**
66    * Accepts single connection, creates instance of
67    * PPB_TCPSocket_Private and stores reference to it in
68    * |tcp_socket|. |callback| is invoked when connection is accepted
69    * or in the case of failure. This method can be called only after
70    * successful Listen call on |tcp_server_socket|.
71    */
72   int32_t (*Accept)(PP_Resource tcp_server_socket,
73                     PP_Resource* tcp_socket,
74                     struct PP_CompletionCallback callback);
75   /**
76    * Returns the current address to which the socket is bound, in the
77    * buffer pointed to by |addr|. This method can be called only after
78    * successful Listen() call and before StopListening() call.
79    */
80   int32_t (*GetLocalAddress)(PP_Resource tcp_server_socket,
81                              struct PP_NetAddress_Private* addr);
82   /**
83    * Cancels all pending callbacks reporting PP_ERROR_ABORTED and
84    * closes the socket. Note: this method is implicitly called when
85    * server socket is destroyed.
86    */
87   void (*StopListening)(PP_Resource tcp_server_socket);
88 };
89
90 typedef struct PPB_TCPServerSocket_Private_0_2 PPB_TCPServerSocket_Private;
91
92 struct PPB_TCPServerSocket_Private_0_1 {
93   PP_Resource (*Create)(PP_Instance instance);
94   PP_Bool (*IsTCPServerSocket)(PP_Resource resource);
95   int32_t (*Listen)(PP_Resource tcp_server_socket,
96                     const struct PP_NetAddress_Private* addr,
97                     int32_t backlog,
98                     struct PP_CompletionCallback callback);
99   int32_t (*Accept)(PP_Resource tcp_server_socket,
100                     PP_Resource* tcp_socket,
101                     struct PP_CompletionCallback callback);
102   void (*StopListening)(PP_Resource tcp_server_socket);
103 };
104 /**
105  * @}
106  */
107
108 #endif  /* PPAPI_C_PRIVATE_PPB_TCP_SERVER_SOCKET_PRIVATE_H_ */
109