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

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: export AssertLockHeld Created 8 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_private_api.h ('k') | ppapi/thunk/ppb_url_loader_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
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/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h" 9 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_udp_socket_private_api.h" 10 #include "ppapi/thunk/ppb_udp_socket_private_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
11 #include "ppapi/thunk/thunk.h" 12 #include "ppapi/thunk/thunk.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace thunk { 15 namespace thunk {
15 16
16 namespace { 17 namespace {
17 18
(...skipping 10 matching lines...) Expand all
28 EnterUDP enter(resource, false); 29 EnterUDP enter(resource, false);
29 return PP_FromBool(enter.succeeded()); 30 return PP_FromBool(enter.succeeded());
30 } 31 }
31 32
32 int32_t Bind(PP_Resource udp_socket, 33 int32_t Bind(PP_Resource udp_socket,
33 const PP_NetAddress_Private *addr, 34 const PP_NetAddress_Private *addr,
34 PP_CompletionCallback callback) { 35 PP_CompletionCallback callback) {
35 EnterUDP enter(udp_socket, callback, true); 36 EnterUDP enter(udp_socket, callback, true);
36 if (enter.failed()) 37 if (enter.failed())
37 return enter.retval(); 38 return enter.retval();
38 return enter.SetResult(enter.object()->Bind(addr, callback)); 39 return enter.SetResult(enter.object()->Bind(addr, enter.callback()));
39 } 40 }
40 41
41 PP_Bool GetBoundAddress(PP_Resource udp_socket, 42 PP_Bool GetBoundAddress(PP_Resource udp_socket,
42 PP_NetAddress_Private* addr) { 43 PP_NetAddress_Private* addr) {
43 EnterUDP enter(udp_socket, true); 44 EnterUDP enter(udp_socket, true);
44 if (enter.failed()) 45 if (enter.failed())
45 return PP_FALSE; 46 return PP_FALSE;
46 return enter.object()->GetBoundAddress(addr); 47 return enter.object()->GetBoundAddress(addr);
47 } 48 }
48 49
49 int32_t RecvFrom(PP_Resource udp_socket, 50 int32_t RecvFrom(PP_Resource udp_socket,
50 char* buffer, 51 char* buffer,
51 int32_t num_bytes, 52 int32_t num_bytes,
52 PP_CompletionCallback callback) { 53 PP_CompletionCallback callback) {
53 EnterUDP enter(udp_socket, callback, true); 54 EnterUDP enter(udp_socket, callback, true);
54 if (enter.failed()) 55 if (enter.failed())
55 return enter.retval(); 56 return enter.retval();
56 return enter.SetResult(enter.object()->RecvFrom(buffer, num_bytes, callback)); 57 return enter.SetResult(enter.object()->RecvFrom(buffer, num_bytes,
58 enter.callback()));
57 } 59 }
58 60
59 PP_Bool GetRecvFromAddress(PP_Resource udp_socket, 61 PP_Bool GetRecvFromAddress(PP_Resource udp_socket,
60 PP_NetAddress_Private* addr) { 62 PP_NetAddress_Private* addr) {
61 EnterUDP enter(udp_socket, true); 63 EnterUDP enter(udp_socket, true);
62 if (enter.failed()) 64 if (enter.failed())
63 return PP_FALSE; 65 return PP_FALSE;
64 return enter.object()->GetRecvFromAddress(addr); 66 return enter.object()->GetRecvFromAddress(addr);
65 } 67 }
66 68
67 int32_t SendTo(PP_Resource udp_socket, 69 int32_t SendTo(PP_Resource udp_socket,
68 const char* buffer, 70 const char* buffer,
69 int32_t num_bytes, 71 int32_t num_bytes,
70 const PP_NetAddress_Private* addr, 72 const PP_NetAddress_Private* addr,
71 PP_CompletionCallback callback) { 73 PP_CompletionCallback callback) {
72 EnterUDP enter(udp_socket, callback, true); 74 EnterUDP enter(udp_socket, callback, true);
73 if (enter.failed()) 75 if (enter.failed())
74 return enter.retval(); 76 return enter.retval();
75 return enter.SetResult(enter.object()->SendTo(buffer, num_bytes, addr, 77 return enter.SetResult(enter.object()->SendTo(buffer, num_bytes, addr,
76 callback)); 78 enter.callback()));
77 } 79 }
78 80
79 void Close(PP_Resource udp_socket) { 81 void Close(PP_Resource udp_socket) {
80 EnterUDP enter(udp_socket, true); 82 EnterUDP enter(udp_socket, true);
81 if (enter.succeeded()) 83 if (enter.succeeded())
82 enter.object()->Close(); 84 enter.object()->Close();
83 } 85 }
84 86
85 const PPB_UDPSocket_Private_0_2 g_ppb_udp_socket_thunk_0_2 = { 87 const PPB_UDPSocket_Private_0_2 g_ppb_udp_socket_thunk_0_2 = {
86 &Create, 88 &Create,
(...skipping 21 matching lines...) Expand all
108 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() { 110 const PPB_UDPSocket_Private_0_2* GetPPB_UDPSocket_Private_0_2_Thunk() {
109 return &g_ppb_udp_socket_thunk_0_2; 111 return &g_ppb_udp_socket_thunk_0_2;
110 } 112 }
111 113
112 const PPB_UDPSocket_Private_0_3* GetPPB_UDPSocket_Private_0_3_Thunk() { 114 const PPB_UDPSocket_Private_0_3* GetPPB_UDPSocket_Private_0_3_Thunk() {
113 return &g_ppb_udp_socket_thunk_0_3; 115 return &g_ppb_udp_socket_thunk_0_3;
114 } 116 }
115 117
116 } // namespace thunk 118 } // namespace thunk
117 } // namespace ppapi 119 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_udp_socket_private_api.h ('k') | ppapi/thunk/ppb_url_loader_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698