1 // Copyright 2013 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 // From ppb_udp_socket.idl modified Thu Jun 20 14:03:55 2013.
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_udp_socket.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppb_instance_api.h"
13 #include "ppapi/thunk/ppb_udp_socket_api.h"
14 #include "ppapi/thunk/resource_creation_api.h"
15 #include "ppapi/thunk/thunk.h"
22 PP_Resource
Create(PP_Instance instance
) {
23 VLOG(4) << "PPB_UDPSocket::Create()";
24 EnterResourceCreation
enter(instance
);
27 return enter
.functions()->CreateUDPSocket(instance
);
30 PP_Bool
IsUDPSocket(PP_Resource resource
) {
31 VLOG(4) << "PPB_UDPSocket::IsUDPSocket()";
32 EnterResource
<PPB_UDPSocket_API
> enter(resource
, false);
33 return PP_FromBool(enter
.succeeded());
36 int32_t Bind(PP_Resource udp_socket
,
38 struct PP_CompletionCallback callback
) {
39 VLOG(4) << "PPB_UDPSocket::Bind()";
40 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, callback
, true);
42 return enter
.retval();
43 return enter
.SetResult(enter
.object()->Bind(addr
, enter
.callback()));
46 PP_Resource
GetBoundAddress(PP_Resource udp_socket
) {
47 VLOG(4) << "PPB_UDPSocket::GetBoundAddress()";
48 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, true);
51 return enter
.object()->GetBoundAddress();
54 int32_t RecvFrom(PP_Resource udp_socket
,
58 struct PP_CompletionCallback callback
) {
59 VLOG(4) << "PPB_UDPSocket::RecvFrom()";
60 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, callback
, true);
62 return enter
.retval();
63 return enter
.SetResult(enter
.object()->RecvFrom(buffer
,
69 int32_t SendTo(PP_Resource udp_socket
,
73 struct PP_CompletionCallback callback
) {
74 VLOG(4) << "PPB_UDPSocket::SendTo()";
75 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, callback
, true);
77 return enter
.retval();
78 return enter
.SetResult(enter
.object()->SendTo(buffer
,
84 void Close(PP_Resource udp_socket
) {
85 VLOG(4) << "PPB_UDPSocket::Close()";
86 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, true);
89 enter
.object()->Close();
92 int32_t SetOption(PP_Resource udp_socket
,
93 PP_UDPSocket_Option name
,
95 struct PP_CompletionCallback callback
) {
96 VLOG(4) << "PPB_UDPSocket::SetOption()";
97 EnterResource
<PPB_UDPSocket_API
> enter(udp_socket
, callback
, true);
99 return enter
.retval();
100 return enter
.SetResult(enter
.object()->SetOption(name
,
105 const PPB_UDPSocket_1_0 g_ppb_udpsocket_thunk_1_0
= {
118 const PPB_UDPSocket_1_0
* GetPPB_UDPSocket_1_0_Thunk() {
119 return &g_ppb_udpsocket_thunk_1_0
;