Don't add an aura tooltip to bubble close buttons on Windows.
[chromium-blink-merge.git] / ppapi / thunk / ppb_udp_socket_private_thunk.cc
bloba4936667d3c38bdccdf83dc520edb18d3600995c
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_completion_callback.h"
6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/c/private/ppb_udp_socket_private.h"
8 #include "ppapi/shared_impl/tracked_callback.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
12 #include "ppapi/thunk/thunk.h"
14 namespace ppapi {
15 namespace thunk {
17 namespace {
19 typedef EnterResource<PPB_UDPSocket_Private_API> EnterUDP;
21 PP_Resource Create(PP_Instance instance) {
22 EnterResourceCreation enter(instance);
23 if (enter.failed())
24 return 0;
25 return enter.functions()->CreateUDPSocketPrivate(instance);
28 PP_Bool IsUDPSocket(PP_Resource resource) {
29 EnterUDP enter(resource, false);
30 return PP_FromBool(enter.succeeded());
33 int32_t SetSocketFeature(PP_Resource udp_socket,
34 PP_UDPSocketFeature_Private name,
35 PP_Var value) {
36 EnterUDP enter(udp_socket, true);
37 if (enter.failed())
38 return PP_ERROR_BADRESOURCE;
39 return enter.object()->SetSocketFeature(name, value);
42 int32_t Bind(PP_Resource udp_socket,
43 const PP_NetAddress_Private *addr,
44 PP_CompletionCallback callback) {
45 EnterUDP enter(udp_socket, callback, true);
46 if (enter.failed())
47 return enter.retval();
48 return enter.SetResult(enter.object()->Bind(addr, enter.callback()));
51 PP_Bool GetBoundAddress(PP_Resource udp_socket,
52 PP_NetAddress_Private* addr) {
53 EnterUDP enter(udp_socket, true);
54 if (enter.failed())
55 return PP_FALSE;
56 return enter.object()->GetBoundAddress(addr);
59 int32_t RecvFrom(PP_Resource udp_socket,
60 char* buffer,
61 int32_t num_bytes,
62 PP_CompletionCallback callback) {
63 #ifdef NDEBUG
64 EnterUDP enter(udp_socket, callback, false);
65 #else
66 EnterUDP enter(udp_socket, callback, true);
67 #endif
68 if (enter.failed())
69 return enter.retval();
70 return enter.SetResult(enter.object()->RecvFrom(buffer, num_bytes,
71 enter.callback()));
74 PP_Bool GetRecvFromAddress(PP_Resource udp_socket,
75 PP_NetAddress_Private* addr) {
76 EnterUDP enter(udp_socket, true);
77 if (enter.failed())
78 return PP_FALSE;
79 return enter.object()->GetRecvFromAddress(addr);
82 int32_t SendTo(PP_Resource udp_socket,
83 const char* buffer,
84 int32_t num_bytes,
85 const PP_NetAddress_Private* addr,
86 PP_CompletionCallback callback) {
87 EnterUDP enter(udp_socket, callback, true);
88 if (enter.failed())
89 return enter.retval();
90 return enter.SetResult(enter.object()->SendTo(buffer, num_bytes, addr,
91 enter.callback()));
94 void Close(PP_Resource udp_socket) {
95 EnterUDP enter(udp_socket, true);
96 if (enter.succeeded())
97 enter.object()->Close();
100 const PPB_UDPSocket_Private_0_2 g_ppb_udp_socket_thunk_0_2 = {
101 &Create,
102 &IsUDPSocket,
103 &Bind,
104 &RecvFrom,
105 &GetRecvFromAddress,
106 &SendTo,
107 &Close
110 const PPB_UDPSocket_Private_0_3 g_ppb_udp_socket_thunk_0_3 = {
111 &Create,
112 &IsUDPSocket,
113 &Bind,
114 &GetBoundAddress,
115 &RecvFrom,
116 &GetRecvFromAddress,
117 &SendTo,
118 &Close
121 const PPB_UDPSocket_Private_0_4 g_ppb_udp_socket_thunk_0_4 = {
122 &Create,
123 &IsUDPSocket,
124 &SetSocketFeature,
125 &Bind,
126 &GetBoundAddress,
127 &RecvFrom,
128 &GetRecvFromAddress,
129 &SendTo,
130 &Close
133 } // namespace
135 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() {
136 return &g_ppb_udp_socket_thunk_0_2;
139 const PPB_UDPSocket_Private_0_3* GetPPB_UDPSocket_Private_0_3_Thunk() {
140 return &g_ppb_udp_socket_thunk_0_3;
143 const PPB_UDPSocket_Private_0_4* GetPPB_UDPSocket_Private_0_4_Thunk() {
144 return &g_ppb_udp_socket_thunk_0_4;
147 } // namespace thunk
148 } // namespace ppapi