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

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

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated TestURLLoader to test blocking callbacks. Created 8 years, 8 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
OLDNEW
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/enter.h" 8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_udp_socket_private_api.h" 9 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 10 #include "ppapi/thunk/resource_creation_api.h"
(...skipping 17 matching lines...) Expand all
28 EnterUDP enter(resource, false); 28 EnterUDP enter(resource, false);
29 return PP_FromBool(enter.succeeded()); 29 return PP_FromBool(enter.succeeded());
30 } 30 }
31 31
32 int32_t Bind(PP_Resource udp_socket, 32 int32_t Bind(PP_Resource udp_socket,
33 const PP_NetAddress_Private *addr, 33 const PP_NetAddress_Private *addr,
34 PP_CompletionCallback callback) { 34 PP_CompletionCallback callback) {
35 EnterUDP enter(udp_socket, callback, true); 35 EnterUDP enter(udp_socket, callback, true);
36 if (enter.failed()) 36 if (enter.failed())
37 return enter.retval(); 37 return enter.retval();
38 return enter.SetResult(enter.object()->Bind(addr, callback)); 38 return enter.SetResult(enter.object()->Bind(addr, enter.callback()));
39 } 39 }
40 40
41 PP_Bool GetBoundAddress(PP_Resource udp_socket, 41 PP_Bool GetBoundAddress(PP_Resource udp_socket,
42 PP_NetAddress_Private* addr) { 42 PP_NetAddress_Private* addr) {
43 EnterUDP enter(udp_socket, true); 43 EnterUDP enter(udp_socket, true);
44 if (enter.failed()) 44 if (enter.failed())
45 return PP_FALSE; 45 return PP_FALSE;
46 return enter.object()->GetBoundAddress(addr); 46 return enter.object()->GetBoundAddress(addr);
47 } 47 }
48 48
49 int32_t RecvFrom(PP_Resource udp_socket, 49 int32_t RecvFrom(PP_Resource udp_socket,
50 char* buffer, 50 char* buffer,
51 int32_t num_bytes, 51 int32_t num_bytes,
52 PP_CompletionCallback callback) { 52 PP_CompletionCallback callback) {
53 EnterUDP enter(udp_socket, callback, true); 53 EnterUDP enter(udp_socket, callback, true);
54 if (enter.failed()) 54 if (enter.failed())
55 return enter.retval(); 55 return enter.retval();
56 return enter.SetResult(enter.object()->RecvFrom(buffer, num_bytes, callback)); 56 return enter.SetResult(enter.object()->RecvFrom(buffer, num_bytes,
57 enter.callback()));
57 } 58 }
58 59
59 PP_Bool GetRecvFromAddress(PP_Resource udp_socket, 60 PP_Bool GetRecvFromAddress(PP_Resource udp_socket,
60 PP_NetAddress_Private* addr) { 61 PP_NetAddress_Private* addr) {
61 EnterUDP enter(udp_socket, true); 62 EnterUDP enter(udp_socket, true);
62 if (enter.failed()) 63 if (enter.failed())
63 return PP_FALSE; 64 return PP_FALSE;
64 return enter.object()->GetRecvFromAddress(addr); 65 return enter.object()->GetRecvFromAddress(addr);
65 } 66 }
66 67
67 int32_t SendTo(PP_Resource udp_socket, 68 int32_t SendTo(PP_Resource udp_socket,
68 const char* buffer, 69 const char* buffer,
69 int32_t num_bytes, 70 int32_t num_bytes,
70 const PP_NetAddress_Private* addr, 71 const PP_NetAddress_Private* addr,
71 PP_CompletionCallback callback) { 72 PP_CompletionCallback callback) {
72 EnterUDP enter(udp_socket, callback, true); 73 EnterUDP enter(udp_socket, callback, true);
73 if (enter.failed()) 74 if (enter.failed())
74 return enter.retval(); 75 return enter.retval();
75 return enter.SetResult(enter.object()->SendTo(buffer, num_bytes, addr, 76 return enter.SetResult(enter.object()->SendTo(buffer, num_bytes, addr,
76 callback)); 77 enter.callback()));
77 } 78 }
78 79
79 void Close(PP_Resource udp_socket) { 80 void Close(PP_Resource udp_socket) {
80 EnterUDP enter(udp_socket, true); 81 EnterUDP enter(udp_socket, true);
81 if (enter.succeeded()) 82 if (enter.succeeded())
82 enter.object()->Close(); 83 enter.object()->Close();
83 } 84 }
84 85
85 const PPB_UDPSocket_Private_0_2 g_ppb_udp_socket_thunk_0_2 = { 86 const PPB_UDPSocket_Private_0_2 g_ppb_udp_socket_thunk_0_2 = {
86 &Create, 87 &Create,
(...skipping 21 matching lines...) Expand all
108 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() { 109 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() {
109 return &g_ppb_udp_socket_thunk_0_2; 110 return &g_ppb_udp_socket_thunk_0_2;
110 } 111 }
111 112
112 const PPB_UDPSocket_Private_0_3* GetPPB_UDPSocket_Private_0_3_Thunk() { 113 const PPB_UDPSocket_Private_0_3* GetPPB_UDPSocket_Private_0_3_Thunk() {
113 return &g_ppb_udp_socket_thunk_0_3; 114 return &g_ppb_udp_socket_thunk_0_3;
114 } 115 }
115 116
116 } // namespace thunk 117 } // namespace thunk
117 } // namespace ppapi 118 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698