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

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

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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_flash_menu_thunk.cc ('k') | ppapi/thunk/ppb_graphics_2d_thunk.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/private/ppb_flash_net_connector.h" 5 #include "ppapi/c/private/ppb_flash_net_connector.h"
6 #include "ppapi/c/pp_completion_callback.h" 6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/thunk/common.h"
9 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_flash_net_connector_api.h" 11 #include "ppapi/thunk/ppb_flash_net_connector_api.h"
11 #include "ppapi/thunk/resource_creation_api.h" 12 #include "ppapi/thunk/resource_creation_api.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace thunk { 15 namespace thunk {
15 16
16 namespace { 17 namespace {
17 18
18 PP_Resource Create(PP_Instance instance) { 19 PP_Resource Create(PP_Instance instance) {
19 EnterFunction<ResourceCreationAPI> enter(instance, true); 20 EnterFunction<ResourceCreationAPI> enter(instance, true);
20 if (enter.failed()) 21 if (enter.failed())
21 return 0; 22 return 0;
22 return enter.functions()->CreateFlashNetConnector(instance); 23 return enter.functions()->CreateFlashNetConnector(instance);
23 } 24 }
24 25
25 PP_Bool IsFlashNetConnector(PP_Resource resource) { 26 PP_Bool IsFlashNetConnector(PP_Resource resource) {
26 EnterResource<PPB_Flash_NetConnector_API> enter(resource, false); 27 EnterResource<PPB_Flash_NetConnector_API> enter(resource, false);
27 return PP_FromBool(enter.succeeded()); 28 return PP_FromBool(enter.succeeded());
28 } 29 }
29 30
30 int32_t ConnectTcp(PP_Resource resource, 31 int32_t ConnectTcp(PP_Resource resource,
31 const char* host, 32 const char* host,
32 uint16_t port, 33 uint16_t port,
33 PP_FileHandle* socket_out, 34 PP_FileHandle* socket_out,
34 PP_Flash_NetAddress* local_addr_out, 35 PP_Flash_NetAddress* local_addr_out,
35 PP_Flash_NetAddress* remote_addr_out, 36 PP_Flash_NetAddress* remote_addr_out,
36 PP_CompletionCallback callback) { 37 PP_CompletionCallback callback) {
37 EnterResource<PPB_Flash_NetConnector_API> enter(resource, true); 38 EnterResource<PPB_Flash_NetConnector_API> enter(resource, true);
38 if (enter.failed()) 39 if (enter.failed())
39 return PP_ERROR_BADRESOURCE; 40 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
40 return enter.object()->ConnectTcp(host, port, socket_out, local_addr_out, 41 int32_t result =
41 remote_addr_out, callback); 42 enter.object()->ConnectTcp(host, port, socket_out, local_addr_out,
43 remote_addr_out, callback);
44 return MayForceCallback(callback, result);
42 } 45 }
43 46
44 int32_t ConnectTcpAddress(PP_Resource resource, 47 int32_t ConnectTcpAddress(PP_Resource resource,
45 const PP_Flash_NetAddress* addr, 48 const PP_Flash_NetAddress* addr,
46 PP_FileHandle* socket_out, 49 PP_FileHandle* socket_out,
47 PP_Flash_NetAddress* local_addr_out, 50 PP_Flash_NetAddress* local_addr_out,
48 PP_Flash_NetAddress* remote_addr_out, 51 PP_Flash_NetAddress* remote_addr_out,
49 PP_CompletionCallback callback) { 52 PP_CompletionCallback callback) {
50 EnterResource<PPB_Flash_NetConnector_API> enter(resource, true); 53 EnterResource<PPB_Flash_NetConnector_API> enter(resource, true);
51 if (enter.failed()) 54 if (enter.failed())
52 return PP_ERROR_BADRESOURCE; 55 return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
53 return enter.object()->ConnectTcpAddress(addr, socket_out, local_addr_out, 56 int32_t result =
57 enter.object()->ConnectTcpAddress(addr, socket_out, local_addr_out,
54 remote_addr_out, callback); 58 remote_addr_out, callback);
59 return MayForceCallback(callback, result);
55 } 60 }
56 61
57 const PPB_Flash_NetConnector g_ppb_flash_net_connector_thunk = { 62 const PPB_Flash_NetConnector g_ppb_flash_net_connector_thunk = {
58 &Create, 63 &Create,
59 &IsFlashNetConnector, 64 &IsFlashNetConnector,
60 &ConnectTcp, 65 &ConnectTcp,
61 &ConnectTcpAddress 66 &ConnectTcpAddress
62 }; 67 };
63 68
64 } // namespace 69 } // namespace
65 70
66 const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk() { 71 const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk() {
67 return &g_ppb_flash_net_connector_thunk; 72 return &g_ppb_flash_net_connector_thunk;
68 } 73 }
69 74
70 } // namespace thunk 75 } // namespace thunk
71 } // namespace ppapi 76 } // namespace ppapi
72
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_flash_menu_thunk.cc ('k') | ppapi/thunk/ppb_graphics_2d_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698