OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
6 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
7 #include "ppapi/c/private/ppb_udp_socket_private.h" | 7 #include "ppapi/c/private/ppb_udp_socket_private.h" |
8 #include "ppapi/thunk/common.h" | 8 #include "ppapi/thunk/common.h" |
9 #include "ppapi/thunk/enter.h" | 9 #include "ppapi/thunk/enter.h" |
10 #include "ppapi/thunk/ppb_udp_socket_private_api.h" | 10 #include "ppapi/thunk/ppb_udp_socket_private_api.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 int32_t Bind(PP_Resource udp_socket, | 31 int32_t Bind(PP_Resource udp_socket, |
32 const PP_NetAddress_Private *addr, | 32 const PP_NetAddress_Private *addr, |
33 PP_CompletionCallback callback) { | 33 PP_CompletionCallback callback) { |
34 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); | 34 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); |
35 if (enter.failed()) | 35 if (enter.failed()) |
36 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | 36 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
37 int32_t result = enter.object()->Bind(addr, callback); | 37 int32_t result = enter.object()->Bind(addr, callback); |
38 return MayForceCallback(callback, result); | 38 return MayForceCallback(callback, result); |
39 } | 39 } |
40 | 40 |
| 41 PP_Bool GetBoundAddress(PP_Resource udp_socket, |
| 42 PP_NetAddress_Private* addr) { |
| 43 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); |
| 44 if (enter.failed()) |
| 45 return PP_FALSE; |
| 46 return enter.object()->GetBoundAddress(addr); |
| 47 } |
| 48 |
41 int32_t RecvFrom(PP_Resource udp_socket, | 49 int32_t RecvFrom(PP_Resource udp_socket, |
42 char* buffer, | 50 char* buffer, |
43 int32_t num_bytes, | 51 int32_t num_bytes, |
44 PP_CompletionCallback callback) { | 52 PP_CompletionCallback callback) { |
45 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); | 53 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); |
46 if (enter.failed()) | 54 if (enter.failed()) |
47 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | 55 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
48 int32_t result = enter.object()->RecvFrom(buffer, | 56 int32_t result = enter.object()->RecvFrom(buffer, |
49 num_bytes, | 57 num_bytes, |
50 callback); | 58 callback); |
(...skipping 23 matching lines...) Expand all Loading... |
74 void Close(PP_Resource udp_socket) { | 82 void Close(PP_Resource udp_socket) { |
75 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); | 83 EnterResource<PPB_UDPSocket_Private_API> enter(udp_socket, true); |
76 if (enter.succeeded()) | 84 if (enter.succeeded()) |
77 enter.object()->Close(); | 85 enter.object()->Close(); |
78 } | 86 } |
79 | 87 |
80 const PPB_UDPSocket_Private g_ppb_udp_socket_thunk = { | 88 const PPB_UDPSocket_Private g_ppb_udp_socket_thunk = { |
81 &Create, | 89 &Create, |
82 &IsUDPSocket, | 90 &IsUDPSocket, |
83 &Bind, | 91 &Bind, |
| 92 &GetBoundAddress, |
84 &RecvFrom, | 93 &RecvFrom, |
85 &GetRecvFromAddress, | 94 &GetRecvFromAddress, |
86 &SendTo, | 95 &SendTo, |
87 &Close | 96 &Close |
88 }; | 97 }; |
89 | 98 |
90 } // namespace | 99 } // namespace |
91 | 100 |
92 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() { | 101 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() { |
93 return &g_ppb_udp_socket_thunk; | 102 return &g_ppb_udp_socket_thunk; |
94 } | 103 } |
95 | 104 |
96 } // namespace thunk | 105 } // namespace thunk |
97 } // namespace ppapi | 106 } // namespace ppapi |
OLD | NEW |