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

Side by Side Diff: ppapi/thunk/ppb_websocket_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_websocket_api.h ('k') | webkit/plugins/ppapi/file_callbacks.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_errors.h" 5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/pp_var.h" 6 #include "ppapi/c/pp_var.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
7 #include "ppapi/thunk/thunk.h" 8 #include "ppapi/thunk/thunk.h"
8 #include "ppapi/thunk/enter.h" 9 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_websocket_api.h" 10 #include "ppapi/thunk/ppb_websocket_api.h"
10 #include "ppapi/thunk/resource_creation_api.h" 11 #include "ppapi/thunk/resource_creation_api.h"
11 12
12 namespace ppapi { 13 namespace ppapi {
13 namespace thunk { 14 namespace thunk {
14 15
15 namespace { 16 namespace {
16 17
(...skipping 13 matching lines...) Expand all
30 31
31 int32_t Connect(PP_Resource resource, 32 int32_t Connect(PP_Resource resource,
32 PP_Var url, 33 PP_Var url,
33 const PP_Var protocols[], 34 const PP_Var protocols[],
34 uint32_t protocol_count, 35 uint32_t protocol_count,
35 PP_CompletionCallback callback) { 36 PP_CompletionCallback callback) {
36 EnterWebSocket enter(resource, callback, false); 37 EnterWebSocket enter(resource, callback, false);
37 if (enter.failed()) 38 if (enter.failed())
38 return enter.retval(); 39 return enter.retval();
39 return enter.SetResult(enter.object()->Connect( 40 return enter.SetResult(enter.object()->Connect(
40 url, protocols, protocol_count, callback)); 41 url, protocols, protocol_count, enter.callback()));
41 } 42 }
42 43
43 int32_t Close(PP_Resource resource, 44 int32_t Close(PP_Resource resource,
44 uint16_t code, 45 uint16_t code,
45 PP_Var reason, 46 PP_Var reason,
46 PP_CompletionCallback callback) { 47 PP_CompletionCallback callback) {
47 EnterWebSocket enter(resource, callback, false); 48 EnterWebSocket enter(resource, callback, false);
48 if (enter.failed()) 49 if (enter.failed())
49 return enter.retval(); 50 return enter.retval();
50 return enter.SetResult(enter.object()->Close(code, reason, callback)); 51 return enter.SetResult(enter.object()->Close(code, reason, enter.callback()));
51 } 52 }
52 53
53 int32_t ReceiveMessage(PP_Resource resource, 54 int32_t ReceiveMessage(PP_Resource resource,
54 PP_Var* message, 55 PP_Var* message,
55 PP_CompletionCallback callback) { 56 PP_CompletionCallback callback) {
56 EnterWebSocket enter(resource, callback, false); 57 EnterWebSocket enter(resource, callback, false);
57 if (enter.failed()) 58 if (enter.failed())
58 return enter.retval(); 59 return enter.retval();
59 return enter.SetResult(enter.object()->ReceiveMessage(message, callback)); 60 return enter.SetResult(enter.object()->ReceiveMessage(message,
61 enter.callback()));
60 } 62 }
61 63
62 int32_t SendMessage(PP_Resource resource, PP_Var message) { 64 int32_t SendMessage(PP_Resource resource, PP_Var message) {
63 EnterWebSocket enter(resource, false); 65 EnterWebSocket enter(resource, false);
64 if (enter.failed()) 66 if (enter.failed())
65 return enter.retval(); 67 return enter.retval();
66 return enter.object()->SendMessage(message); 68 return enter.object()->SendMessage(message);
67 } 69 }
68 70
69 uint64_t GetBufferedAmount(PP_Resource resource) { 71 uint64_t GetBufferedAmount(PP_Resource resource) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 }; 142 };
141 143
142 } // namespace 144 } // namespace
143 145
144 const PPB_WebSocket_1_0* GetPPB_WebSocket_1_0_Thunk() { 146 const PPB_WebSocket_1_0* GetPPB_WebSocket_1_0_Thunk() {
145 return &g_ppb_websocket_1_0_thunk; 147 return &g_ppb_websocket_1_0_thunk;
146 } 148 }
147 149
148 } // namespace thunk 150 } // namespace thunk
149 } // namespace ppapi 151 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_websocket_api.h ('k') | webkit/plugins/ppapi/file_callbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698