OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // From ppb_tcp_socket.idl modified Thu Jun 20 16:36:53 2013. | 5 // From ppb_tcp_socket.idl modified Sun Sep 15 16:14:21 2013. |
6 | 6 |
7 #include "ppapi/c/pp_completion_callback.h" | 7 #include "ppapi/c/pp_completion_callback.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/c/ppb_tcp_socket.h" | 9 #include "ppapi/c/ppb_tcp_socket.h" |
10 #include "ppapi/shared_impl/tracked_callback.h" | 10 #include "ppapi/shared_impl/tracked_callback.h" |
11 #include "ppapi/thunk/enter.h" | 11 #include "ppapi/thunk/enter.h" |
12 #include "ppapi/thunk/ppb_instance_api.h" | 12 #include "ppapi/thunk/ppb_instance_api.h" |
13 #include "ppapi/thunk/ppb_tcp_socket_api.h" | 13 #include "ppapi/thunk/ppb_tcp_socket_api.h" |
14 #include "ppapi/thunk/resource_creation_api.h" | 14 #include "ppapi/thunk/resource_creation_api.h" |
15 #include "ppapi/thunk/thunk.h" | 15 #include "ppapi/thunk/thunk.h" |
16 | 16 |
17 namespace ppapi { | 17 namespace ppapi { |
18 namespace thunk { | 18 namespace thunk { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
| 22 PP_Resource Create_1_0(PP_Instance instance) { |
| 23 VLOG(4) << "PPB_TCPSocket::Create_1_0()"; |
| 24 EnterResourceCreation enter(instance); |
| 25 if (enter.failed()) |
| 26 return 0; |
| 27 return enter.functions()->CreateTCPSocket1_0(instance); |
| 28 } |
| 29 |
22 PP_Resource Create(PP_Instance instance) { | 30 PP_Resource Create(PP_Instance instance) { |
23 VLOG(4) << "PPB_TCPSocket::Create()"; | 31 VLOG(4) << "PPB_TCPSocket::Create()"; |
24 EnterResourceCreation enter(instance); | 32 EnterResourceCreation enter(instance); |
25 if (enter.failed()) | 33 if (enter.failed()) |
26 return 0; | 34 return 0; |
27 return enter.functions()->CreateTCPSocket(instance); | 35 return enter.functions()->CreateTCPSocket(instance); |
28 } | 36 } |
29 | 37 |
30 PP_Bool IsTCPSocket(PP_Resource resource) { | 38 PP_Bool IsTCPSocket(PP_Resource resource) { |
31 VLOG(4) << "PPB_TCPSocket::IsTCPSocket()"; | 39 VLOG(4) << "PPB_TCPSocket::IsTCPSocket()"; |
32 EnterResource<PPB_TCPSocket_API> enter(resource, false); | 40 EnterResource<PPB_TCPSocket_API> enter(resource, false); |
33 return PP_FromBool(enter.succeeded()); | 41 return PP_FromBool(enter.succeeded()); |
34 } | 42 } |
35 | 43 |
| 44 int32_t Bind(PP_Resource tcp_socket, |
| 45 PP_Resource addr, |
| 46 struct PP_CompletionCallback callback) { |
| 47 VLOG(4) << "PPB_TCPSocket::Bind()"; |
| 48 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 49 if (enter.failed()) |
| 50 return enter.retval(); |
| 51 return enter.SetResult(enter.object()->Bind(addr, enter.callback())); |
| 52 } |
| 53 |
36 int32_t Connect(PP_Resource tcp_socket, | 54 int32_t Connect(PP_Resource tcp_socket, |
37 PP_Resource addr, | 55 PP_Resource addr, |
38 struct PP_CompletionCallback callback) { | 56 struct PP_CompletionCallback callback) { |
39 VLOG(4) << "PPB_TCPSocket::Connect()"; | 57 VLOG(4) << "PPB_TCPSocket::Connect()"; |
40 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 58 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
41 if (enter.failed()) | 59 if (enter.failed()) |
42 return enter.retval(); | 60 return enter.retval(); |
43 return enter.SetResult(enter.object()->Connect(addr, enter.callback())); | 61 return enter.SetResult(enter.object()->Connect(addr, enter.callback())); |
44 } | 62 } |
45 | 63 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 struct PP_CompletionCallback callback) { | 96 struct PP_CompletionCallback callback) { |
79 VLOG(4) << "PPB_TCPSocket::Write()"; | 97 VLOG(4) << "PPB_TCPSocket::Write()"; |
80 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 98 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
81 if (enter.failed()) | 99 if (enter.failed()) |
82 return enter.retval(); | 100 return enter.retval(); |
83 return enter.SetResult(enter.object()->Write(buffer, | 101 return enter.SetResult(enter.object()->Write(buffer, |
84 bytes_to_write, | 102 bytes_to_write, |
85 enter.callback())); | 103 enter.callback())); |
86 } | 104 } |
87 | 105 |
| 106 int32_t Listen(PP_Resource tcp_socket, |
| 107 int32_t backlog, |
| 108 struct PP_CompletionCallback callback) { |
| 109 VLOG(4) << "PPB_TCPSocket::Listen()"; |
| 110 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 111 if (enter.failed()) |
| 112 return enter.retval(); |
| 113 return enter.SetResult(enter.object()->Listen(backlog, enter.callback())); |
| 114 } |
| 115 |
| 116 int32_t Accept(PP_Resource tcp_socket, |
| 117 PP_Resource* accepted_tcp_socket, |
| 118 struct PP_CompletionCallback callback) { |
| 119 VLOG(4) << "PPB_TCPSocket::Accept()"; |
| 120 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
| 121 if (enter.failed()) |
| 122 return enter.retval(); |
| 123 return enter.SetResult(enter.object()->Accept(accepted_tcp_socket, |
| 124 enter.callback())); |
| 125 } |
| 126 |
88 void Close(PP_Resource tcp_socket) { | 127 void Close(PP_Resource tcp_socket) { |
89 VLOG(4) << "PPB_TCPSocket::Close()"; | 128 VLOG(4) << "PPB_TCPSocket::Close()"; |
90 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true); | 129 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true); |
91 if (enter.failed()) | 130 if (enter.failed()) |
92 return; | 131 return; |
93 enter.object()->Close(); | 132 enter.object()->Close(); |
94 } | 133 } |
95 | 134 |
96 int32_t SetOption(PP_Resource tcp_socket, | 135 int32_t SetOption(PP_Resource tcp_socket, |
97 PP_TCPSocket_Option name, | 136 PP_TCPSocket_Option name, |
98 struct PP_Var value, | 137 struct PP_Var value, |
99 struct PP_CompletionCallback callback) { | 138 struct PP_CompletionCallback callback) { |
100 VLOG(4) << "PPB_TCPSocket::SetOption()"; | 139 VLOG(4) << "PPB_TCPSocket::SetOption()"; |
101 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); | 140 EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); |
102 if (enter.failed()) | 141 if (enter.failed()) |
103 return enter.retval(); | 142 return enter.retval(); |
104 return enter.SetResult(enter.object()->SetOption(name, | 143 return enter.SetResult(enter.object()->SetOption(name, |
105 value, | 144 value, |
106 enter.callback())); | 145 enter.callback())); |
107 } | 146 } |
108 | 147 |
109 const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { | 148 const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { |
110 &Create, | 149 &Create_1_0, |
111 &IsTCPSocket, | 150 &IsTCPSocket, |
112 &Connect, | 151 &Connect, |
113 &GetLocalAddress, | 152 &GetLocalAddress, |
114 &GetRemoteAddress, | 153 &GetRemoteAddress, |
115 &Read, | 154 &Read, |
116 &Write, | 155 &Write, |
117 &Close, | 156 &Close, |
118 &SetOption | 157 &SetOption |
119 }; | 158 }; |
| 159 |
| 160 const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { |
| 161 &Create, |
| 162 &IsTCPSocket, |
| 163 &Bind, |
| 164 &Connect, |
| 165 &GetLocalAddress, |
| 166 &GetRemoteAddress, |
| 167 &Read, |
| 168 &Write, |
| 169 &Listen, |
| 170 &Accept, |
| 171 &Close, |
| 172 &SetOption |
| 173 }; |
120 | 174 |
121 } // namespace | 175 } // namespace |
122 | 176 |
123 const PPB_TCPSocket_1_0* GetPPB_TCPSocket_1_0_Thunk() { | 177 const PPB_TCPSocket_1_0* GetPPB_TCPSocket_1_0_Thunk() { |
124 return &g_ppb_tcpsocket_thunk_1_0; | 178 return &g_ppb_tcpsocket_thunk_1_0; |
125 } | 179 } |
126 | 180 |
| 181 const PPB_TCPSocket_1_1* GetPPB_TCPSocket_1_1_Thunk() { |
| 182 return &g_ppb_tcpsocket_thunk_1_1; |
| 183 } |
| 184 |
127 } // namespace thunk | 185 } // namespace thunk |
128 } // namespace ppapi | 186 } // namespace ppapi |
OLD | NEW |