Add histogram for content verification failures of policy based installs
[chromium-blink-merge.git] / ppapi / thunk / ppb_tcp_server_socket_private_thunk.cc
blobbbfe16dade488178b1b66c4a058a3e44d30c2ba5
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"
13 namespace ppapi {
14 namespace thunk {
16 namespace {
18 typedef EnterResource<PPB_TCPServerSocket_Private_API> EnterTCPServer;
20 PP_Resource Create(PP_Instance instance) {
21 EnterResourceCreation enter(instance);
22 if (enter.failed())
23 return 0;
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,
34 int32_t backlog,
35 PP_CompletionCallback callback) {
36 EnterTCPServer enter(tcp_server_socket, callback, true);
37 if (enter.failed())
38 return enter.retval();
39 return enter.SetResult(enter.object()->Listen(addr, backlog,
40 enter.callback()));
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);
47 if (enter.failed())
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);
55 if (enter.failed())
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 = {
67 Create,
68 IsTCPServerSocket,
69 Listen,
70 Accept,
71 StopListening
74 const PPB_TCPServerSocket_Private_0_2 g_ppb_tcp_server_socket_thunk_0_2 = {
75 Create,
76 IsTCPServerSocket,
77 Listen,
78 Accept,
79 GetLocalAddress,
80 StopListening,
83 } // namespace
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;
95 } // namespace thunk
96 } // namespace ppapi