Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: ppapi/thunk/ppb_udp_socket_dev_thunk.cc

Issue 16282005: Introduce PPB_UDPSocket_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/ppb_udp_socket_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 // From dev/ppb_udp_socket_dev.idl modified Fri Jun 07 14:22:41 2013.
6
7 #include "ppapi/c/dev/ppb_udp_socket_dev.h"
8 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/pp_errors.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"
16
17 namespace ppapi {
18 namespace thunk {
19
20 namespace {
21
22 PP_Resource Create(PP_Instance instance) {
23 VLOG(4) << "PPB_UDPSocket_Dev::Create()";
24 EnterResourceCreation enter(instance);
25 if (enter.failed())
26 return 0;
27 return enter.functions()->CreateUDPSocket(instance);
28 }
29
30 PP_Bool IsUDPSocket(PP_Resource resource) {
31 VLOG(4) << "PPB_UDPSocket_Dev::IsUDPSocket()";
32 EnterResource<PPB_UDPSocket_API> enter(resource, false);
33 return PP_FromBool(enter.succeeded());
34 }
35
36 int32_t Bind(PP_Resource udp_socket,
37 PP_Resource addr,
38 struct PP_CompletionCallback callback) {
39 VLOG(4) << "PPB_UDPSocket_Dev::Bind()";
40 EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true);
41 if (enter.failed())
42 return enter.retval();
43 return enter.SetResult(enter.object()->Bind(addr, enter.callback()));
44 }
45
46 PP_Resource GetBoundAddress(PP_Resource udp_socket) {
47 VLOG(4) << "PPB_UDPSocket_Dev::GetBoundAddress()";
48 EnterResource<PPB_UDPSocket_API> enter(udp_socket, true);
49 if (enter.failed())
50 return 0;
51 return enter.object()->GetBoundAddress();
52 }
53
54 int32_t RecvFrom(PP_Resource udp_socket,
55 char* buffer,
56 int32_t num_bytes,
57 PP_Resource* addr,
58 struct PP_CompletionCallback callback) {
59 VLOG(4) << "PPB_UDPSocket_Dev::RecvFrom()";
60 EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true);
61 if (enter.failed())
62 return enter.retval();
63 return enter.SetResult(enter.object()->RecvFrom(buffer,
64 num_bytes,
65 addr,
66 enter.callback()));
67 }
68
69 int32_t SendTo(PP_Resource udp_socket,
70 const char* buffer,
71 int32_t num_bytes,
72 PP_Resource addr,
73 struct PP_CompletionCallback callback) {
74 VLOG(4) << "PPB_UDPSocket_Dev::SendTo()";
75 EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true);
76 if (enter.failed())
77 return enter.retval();
78 return enter.SetResult(enter.object()->SendTo(buffer,
79 num_bytes,
80 addr,
81 enter.callback()));
82 }
83
84 void Close(PP_Resource udp_socket) {
85 VLOG(4) << "PPB_UDPSocket_Dev::Close()";
86 EnterResource<PPB_UDPSocket_API> enter(udp_socket, true);
87 if (enter.failed())
88 return;
89 enter.object()->Close();
90 }
91
92 int32_t SetOption(PP_Resource udp_socket,
93 PP_UDPSocket_Option_Dev name,
94 struct PP_Var value,
95 struct PP_CompletionCallback callback) {
96 VLOG(4) << "PPB_UDPSocket_Dev::SetOption()";
97 EnterResource<PPB_UDPSocket_API> enter(udp_socket, callback, true);
98 if (enter.failed())
99 return enter.retval();
100 return enter.SetResult(enter.object()->SetOption(name,
101 value,
102 enter.callback()));
103 }
104
105 const PPB_UDPSocket_Dev_0_1 g_ppb_udpsocket_dev_thunk_0_1 = {
106 &Create,
107 &IsUDPSocket,
108 &Bind,
109 &GetBoundAddress,
110 &RecvFrom,
111 &SendTo,
112 &Close,
113 &SetOption
114 };
115
116 } // namespace
117
118 const PPB_UDPSocket_Dev_0_1* GetPPB_UDPSocket_Dev_0_1_Thunk() {
119 return &g_ppb_udpsocket_dev_thunk_0_1;
120 }
121
122 } // namespace thunk
123 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_udp_socket_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698