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.
5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/private/ppb_tcp_server_socket_private.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
10 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h"
18 typedef EnterResource
<PPB_TCPServerSocket_Private_API
> EnterTCPServer
;
20 PP_Resource
Create(PP_Instance instance
) {
21 EnterResourceCreation
enter(instance
);
24 return enter
.functions()->CreateTCPServerSocketPrivate(instance
);
27 PP_Bool
IsTCPServerSocket(PP_Resource resource
) {
28 EnterTCPServer
enter(resource
, false);
29 return PP_FromBool(enter
.succeeded());
32 int32_t Listen(PP_Resource tcp_server_socket
,
33 const PP_NetAddress_Private
* addr
,
35 PP_CompletionCallback callback
) {
36 EnterTCPServer
enter(tcp_server_socket
, callback
, true);
38 return enter
.retval();
39 return enter
.SetResult(enter
.object()->Listen(addr
, backlog
,
43 int32_t Accept(PP_Resource tcp_server_socket
,
44 PP_Resource
* tcp_socket
,
45 PP_CompletionCallback callback
) {
46 EnterTCPServer
enter(tcp_server_socket
, callback
, true);
48 return enter
.retval();
49 return enter
.SetResult(enter
.object()->Accept(tcp_socket
, enter
.callback()));
52 int32_t GetLocalAddress(PP_Resource tcp_server_socket
,
53 PP_NetAddress_Private
* addr
) {
54 EnterTCPServer
enter(tcp_server_socket
, true);
56 return PP_ERROR_BADRESOURCE
;
57 return enter
.object()->GetLocalAddress(addr
);
60 void StopListening(PP_Resource tcp_server_socket
) {
61 EnterTCPServer
enter(tcp_server_socket
, true);
62 if (enter
.succeeded())
63 enter
.object()->StopListening();
66 const PPB_TCPServerSocket_Private_0_1 g_ppb_tcp_server_socket_thunk_0_1
= {
74 const PPB_TCPServerSocket_Private_0_2 g_ppb_tcp_server_socket_thunk_0_2
= {
85 const PPB_TCPServerSocket_Private_0_1
*
86 GetPPB_TCPServerSocket_Private_0_1_Thunk() {
87 return &g_ppb_tcp_server_socket_thunk_0_1
;
90 const PPB_TCPServerSocket_Private_0_2
*
91 GetPPB_TCPServerSocket_Private_0_2_Thunk() {
92 return &g_ppb_tcp_server_socket_thunk_0_2
;