| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h" | 7 #include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h" |
| 8 #include "ppapi/shared_impl/tracked_callback.h" | 8 #include "ppapi/shared_impl/tracked_callback.h" |
| 9 #include "ppapi/thunk/enter.h" | 9 #include "ppapi/thunk/enter.h" |
| 10 #include "ppapi/thunk/extensions_common_api.h" | 10 #include "ppapi/thunk/extensions_common_api.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 PP_CompletionCallback callback) { | 25 PP_CompletionCallback callback) { |
| 26 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 26 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 27 if (enter.failed()) | 27 if (enter.failed()) |
| 28 return enter.retval(); | 28 return enter.retval(); |
| 29 | 29 |
| 30 std::vector<PP_Var> input_args; | 30 std::vector<PP_Var> input_args; |
| 31 std::vector<PP_Var*> output_args; | 31 std::vector<PP_Var*> output_args; |
| 32 input_args.push_back(type); | 32 input_args.push_back(type); |
| 33 input_args.push_back(options); | 33 input_args.push_back(options); |
| 34 output_args.push_back(create_info); | 34 output_args.push_back(create_info); |
| 35 return enter.SetResult(enter.functions()->Call( | 35 return enter.SetResult(enter.functions()->CallRenderer( |
| 36 "socket.create", input_args, output_args, enter.callback())); | 36 "socket.create", input_args, output_args, enter.callback())); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void Destroy(PP_Instance instance, PP_Var socket_id) { | 39 void Destroy(PP_Instance instance, PP_Var socket_id) { |
| 40 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); | 40 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); |
| 41 if (enter.failed()) | 41 if (enter.failed()) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 std::vector<PP_Var> args; | 44 std::vector<PP_Var> args; |
| 45 args.push_back(socket_id); | 45 args.push_back(socket_id); |
| 46 enter.functions()->Post("socket.destroy", args); | 46 enter.functions()->PostRenderer("socket.destroy", args); |
| 47 } | 47 } |
| 48 | 48 |
| 49 int32_t Connect(PP_Instance instance, | 49 int32_t Connect(PP_Instance instance, |
| 50 PP_Var socket_id, | 50 PP_Var socket_id, |
| 51 PP_Var hostname, | 51 PP_Var hostname, |
| 52 PP_Var port, | 52 PP_Var port, |
| 53 PP_Var* result, | 53 PP_Var* result, |
| 54 PP_CompletionCallback callback) { | 54 PP_CompletionCallback callback) { |
| 55 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 55 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 56 if (enter.failed()) | 56 if (enter.failed()) |
| 57 return enter.retval(); | 57 return enter.retval(); |
| 58 | 58 |
| 59 std::vector<PP_Var> input_args; | 59 std::vector<PP_Var> input_args; |
| 60 std::vector<PP_Var*> output_args; | 60 std::vector<PP_Var*> output_args; |
| 61 input_args.push_back(socket_id); | 61 input_args.push_back(socket_id); |
| 62 input_args.push_back(hostname); | 62 input_args.push_back(hostname); |
| 63 input_args.push_back(port); | 63 input_args.push_back(port); |
| 64 output_args.push_back(result); | 64 output_args.push_back(result); |
| 65 return enter.SetResult(enter.functions()->Call( | 65 return enter.SetResult(enter.functions()->CallRenderer( |
| 66 "socket.connect", input_args, output_args, enter.callback())); | 66 "socket.connect", input_args, output_args, enter.callback())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 int32_t Bind(PP_Instance instance, | 69 int32_t Bind(PP_Instance instance, |
| 70 PP_Var socket_id, | 70 PP_Var socket_id, |
| 71 PP_Var address, | 71 PP_Var address, |
| 72 PP_Var port, | 72 PP_Var port, |
| 73 PP_Var* result, | 73 PP_Var* result, |
| 74 PP_CompletionCallback callback) { | 74 PP_CompletionCallback callback) { |
| 75 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 75 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 76 if (enter.failed()) | 76 if (enter.failed()) |
| 77 return enter.retval(); | 77 return enter.retval(); |
| 78 | 78 |
| 79 std::vector<PP_Var> input_args; | 79 std::vector<PP_Var> input_args; |
| 80 std::vector<PP_Var*> output_args; | 80 std::vector<PP_Var*> output_args; |
| 81 input_args.push_back(socket_id); | 81 input_args.push_back(socket_id); |
| 82 input_args.push_back(address); | 82 input_args.push_back(address); |
| 83 input_args.push_back(port); | 83 input_args.push_back(port); |
| 84 output_args.push_back(result); | 84 output_args.push_back(result); |
| 85 return enter.SetResult(enter.functions()->Call( | 85 return enter.SetResult(enter.functions()->CallRenderer( |
| 86 "socket.bind", input_args, output_args, enter.callback())); | 86 "socket.bind", input_args, output_args, enter.callback())); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void Disconnect(PP_Instance instance, PP_Var socket_id) { | 89 void Disconnect(PP_Instance instance, PP_Var socket_id) { |
| 90 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); | 90 EnterInstanceAPI<ExtensionsCommon_API> enter(instance); |
| 91 if (enter.failed()) | 91 if (enter.failed()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 std::vector<PP_Var> args; | 94 std::vector<PP_Var> args; |
| 95 args.push_back(socket_id); | 95 args.push_back(socket_id); |
| 96 enter.functions()->Post("socket.disconnect", args); | 96 enter.functions()->PostRenderer("socket.disconnect", args); |
| 97 } | 97 } |
| 98 | 98 |
| 99 int32_t Read(PP_Instance instance, | 99 int32_t Read(PP_Instance instance, |
| 100 PP_Var socket_id, | 100 PP_Var socket_id, |
| 101 PP_Var buffer_size, | 101 PP_Var buffer_size, |
| 102 PP_Ext_Socket_ReadInfo_Dev* read_info, | 102 PP_Ext_Socket_ReadInfo_Dev* read_info, |
| 103 PP_CompletionCallback callback) { | 103 PP_CompletionCallback callback) { |
| 104 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 104 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 105 if (enter.failed()) | 105 if (enter.failed()) |
| 106 return enter.retval(); | 106 return enter.retval(); |
| 107 | 107 |
| 108 std::vector<PP_Var> input_args; | 108 std::vector<PP_Var> input_args; |
| 109 std::vector<PP_Var*> output_args; | 109 std::vector<PP_Var*> output_args; |
| 110 input_args.push_back(socket_id); | 110 input_args.push_back(socket_id); |
| 111 input_args.push_back(buffer_size); | 111 input_args.push_back(buffer_size); |
| 112 output_args.push_back(read_info); | 112 output_args.push_back(read_info); |
| 113 return enter.SetResult(enter.functions()->Call( | 113 return enter.SetResult(enter.functions()->CallRenderer( |
| 114 "socket.read", input_args, output_args, enter.callback())); | 114 "socket.read", input_args, output_args, enter.callback())); |
| 115 } | 115 } |
| 116 | 116 |
| 117 int32_t Write(PP_Instance instance, | 117 int32_t Write(PP_Instance instance, |
| 118 PP_Var socket_id, | 118 PP_Var socket_id, |
| 119 PP_Var data, | 119 PP_Var data, |
| 120 PP_Ext_Socket_WriteInfo_Dev* write_info, | 120 PP_Ext_Socket_WriteInfo_Dev* write_info, |
| 121 PP_CompletionCallback callback) { | 121 PP_CompletionCallback callback) { |
| 122 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 122 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 123 if (enter.failed()) | 123 if (enter.failed()) |
| 124 return enter.retval(); | 124 return enter.retval(); |
| 125 | 125 |
| 126 std::vector<PP_Var> input_args; | 126 std::vector<PP_Var> input_args; |
| 127 std::vector<PP_Var*> output_args; | 127 std::vector<PP_Var*> output_args; |
| 128 input_args.push_back(socket_id); | 128 input_args.push_back(socket_id); |
| 129 input_args.push_back(data); | 129 input_args.push_back(data); |
| 130 output_args.push_back(write_info); | 130 output_args.push_back(write_info); |
| 131 return enter.SetResult(enter.functions()->Call( | 131 return enter.SetResult(enter.functions()->CallRenderer( |
| 132 "socket.write", input_args, output_args, enter.callback())); | 132 "socket.write", input_args, output_args, enter.callback())); |
| 133 } | 133 } |
| 134 | 134 |
| 135 int32_t RecvFrom(PP_Instance instance, | 135 int32_t RecvFrom(PP_Instance instance, |
| 136 PP_Var socket_id, | 136 PP_Var socket_id, |
| 137 PP_Var buffer_size, | 137 PP_Var buffer_size, |
| 138 PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info, | 138 PP_Ext_Socket_RecvFromInfo_Dev* recv_from_info, |
| 139 PP_CompletionCallback callback) { | 139 PP_CompletionCallback callback) { |
| 140 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 140 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 141 if (enter.failed()) | 141 if (enter.failed()) |
| 142 return enter.retval(); | 142 return enter.retval(); |
| 143 | 143 |
| 144 std::vector<PP_Var> input_args; | 144 std::vector<PP_Var> input_args; |
| 145 std::vector<PP_Var*> output_args; | 145 std::vector<PP_Var*> output_args; |
| 146 input_args.push_back(socket_id); | 146 input_args.push_back(socket_id); |
| 147 input_args.push_back(buffer_size); | 147 input_args.push_back(buffer_size); |
| 148 output_args.push_back(recv_from_info); | 148 output_args.push_back(recv_from_info); |
| 149 return enter.SetResult(enter.functions()->Call( | 149 return enter.SetResult(enter.functions()->CallRenderer( |
| 150 "socket.recvFrom", input_args, output_args, enter.callback())); | 150 "socket.recvFrom", input_args, output_args, enter.callback())); |
| 151 } | 151 } |
| 152 | 152 |
| 153 int32_t SendTo(PP_Instance instance, | 153 int32_t SendTo(PP_Instance instance, |
| 154 PP_Var socket_id, | 154 PP_Var socket_id, |
| 155 PP_Var data, | 155 PP_Var data, |
| 156 PP_Var address, | 156 PP_Var address, |
| 157 PP_Var port, | 157 PP_Var port, |
| 158 PP_Ext_Socket_WriteInfo_Dev* write_info, | 158 PP_Ext_Socket_WriteInfo_Dev* write_info, |
| 159 PP_CompletionCallback callback) { | 159 PP_CompletionCallback callback) { |
| 160 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 160 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 161 if (enter.failed()) | 161 if (enter.failed()) |
| 162 return enter.retval(); | 162 return enter.retval(); |
| 163 | 163 |
| 164 std::vector<PP_Var> input_args; | 164 std::vector<PP_Var> input_args; |
| 165 std::vector<PP_Var*> output_args; | 165 std::vector<PP_Var*> output_args; |
| 166 input_args.push_back(socket_id); | 166 input_args.push_back(socket_id); |
| 167 input_args.push_back(data); | 167 input_args.push_back(data); |
| 168 input_args.push_back(address); | 168 input_args.push_back(address); |
| 169 input_args.push_back(port); | 169 input_args.push_back(port); |
| 170 output_args.push_back(write_info); | 170 output_args.push_back(write_info); |
| 171 return enter.SetResult(enter.functions()->Call( | 171 return enter.SetResult(enter.functions()->CallRenderer( |
| 172 "socket.sendTo", input_args, output_args, enter.callback())); | 172 "socket.sendTo", input_args, output_args, enter.callback())); |
| 173 } | 173 } |
| 174 | 174 |
| 175 int32_t Listen(PP_Instance instance, | 175 int32_t Listen(PP_Instance instance, |
| 176 PP_Var socket_id, | 176 PP_Var socket_id, |
| 177 PP_Var address, | 177 PP_Var address, |
| 178 PP_Var port, | 178 PP_Var port, |
| 179 PP_Var backlog, | 179 PP_Var backlog, |
| 180 PP_Var* result, | 180 PP_Var* result, |
| 181 PP_CompletionCallback callback) { | 181 PP_CompletionCallback callback) { |
| 182 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 182 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 183 if (enter.failed()) | 183 if (enter.failed()) |
| 184 return enter.retval(); | 184 return enter.retval(); |
| 185 | 185 |
| 186 std::vector<PP_Var> input_args; | 186 std::vector<PP_Var> input_args; |
| 187 std::vector<PP_Var*> output_args; | 187 std::vector<PP_Var*> output_args; |
| 188 input_args.push_back(socket_id); | 188 input_args.push_back(socket_id); |
| 189 input_args.push_back(address); | 189 input_args.push_back(address); |
| 190 input_args.push_back(port); | 190 input_args.push_back(port); |
| 191 input_args.push_back(backlog); | 191 input_args.push_back(backlog); |
| 192 output_args.push_back(result); | 192 output_args.push_back(result); |
| 193 return enter.SetResult(enter.functions()->Call( | 193 return enter.SetResult(enter.functions()->CallRenderer( |
| 194 "socket.listen", input_args, output_args, enter.callback())); | 194 "socket.listen", input_args, output_args, enter.callback())); |
| 195 } | 195 } |
| 196 | 196 |
| 197 int32_t Accept(PP_Instance instance, | 197 int32_t Accept(PP_Instance instance, |
| 198 PP_Var socket_id, | 198 PP_Var socket_id, |
| 199 PP_Ext_Socket_AcceptInfo_Dev* accept_info, | 199 PP_Ext_Socket_AcceptInfo_Dev* accept_info, |
| 200 PP_CompletionCallback callback) { | 200 PP_CompletionCallback callback) { |
| 201 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 201 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 202 if (enter.failed()) | 202 if (enter.failed()) |
| 203 return enter.retval(); | 203 return enter.retval(); |
| 204 | 204 |
| 205 std::vector<PP_Var> input_args; | 205 std::vector<PP_Var> input_args; |
| 206 std::vector<PP_Var*> output_args; | 206 std::vector<PP_Var*> output_args; |
| 207 input_args.push_back(socket_id); | 207 input_args.push_back(socket_id); |
| 208 output_args.push_back(accept_info); | 208 output_args.push_back(accept_info); |
| 209 return enter.SetResult(enter.functions()->Call( | 209 return enter.SetResult(enter.functions()->CallRenderer( |
| 210 "socket.accept", input_args, output_args, enter.callback())); | 210 "socket.accept", input_args, output_args, enter.callback())); |
| 211 } | 211 } |
| 212 | 212 |
| 213 int32_t SetKeepAlive(PP_Instance instance, | 213 int32_t SetKeepAlive(PP_Instance instance, |
| 214 PP_Var socket_id, | 214 PP_Var socket_id, |
| 215 PP_Var enable, | 215 PP_Var enable, |
| 216 PP_Var delay, | 216 PP_Var delay, |
| 217 PP_Var* result, | 217 PP_Var* result, |
| 218 PP_CompletionCallback callback) { | 218 PP_CompletionCallback callback) { |
| 219 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 219 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 220 if (enter.failed()) | 220 if (enter.failed()) |
| 221 return enter.retval(); | 221 return enter.retval(); |
| 222 | 222 |
| 223 std::vector<PP_Var> input_args; | 223 std::vector<PP_Var> input_args; |
| 224 std::vector<PP_Var*> output_args; | 224 std::vector<PP_Var*> output_args; |
| 225 input_args.push_back(socket_id); | 225 input_args.push_back(socket_id); |
| 226 input_args.push_back(enable); | 226 input_args.push_back(enable); |
| 227 input_args.push_back(delay); | 227 input_args.push_back(delay); |
| 228 output_args.push_back(result); | 228 output_args.push_back(result); |
| 229 return enter.SetResult(enter.functions()->Call( | 229 return enter.SetResult(enter.functions()->CallRenderer( |
| 230 "socket.setKeepAlive", input_args, output_args, enter.callback())); | 230 "socket.setKeepAlive", input_args, output_args, enter.callback())); |
| 231 } | 231 } |
| 232 | 232 |
| 233 int32_t SetNoDelay(PP_Instance instance, | 233 int32_t SetNoDelay(PP_Instance instance, |
| 234 PP_Var socket_id, | 234 PP_Var socket_id, |
| 235 PP_Var no_delay, | 235 PP_Var no_delay, |
| 236 PP_Var* result, | 236 PP_Var* result, |
| 237 PP_CompletionCallback callback) { | 237 PP_CompletionCallback callback) { |
| 238 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 238 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 239 if (enter.failed()) | 239 if (enter.failed()) |
| 240 return enter.retval(); | 240 return enter.retval(); |
| 241 | 241 |
| 242 std::vector<PP_Var> input_args; | 242 std::vector<PP_Var> input_args; |
| 243 std::vector<PP_Var*> output_args; | 243 std::vector<PP_Var*> output_args; |
| 244 input_args.push_back(socket_id); | 244 input_args.push_back(socket_id); |
| 245 input_args.push_back(no_delay); | 245 input_args.push_back(no_delay); |
| 246 output_args.push_back(result); | 246 output_args.push_back(result); |
| 247 return enter.SetResult(enter.functions()->Call( | 247 return enter.SetResult(enter.functions()->CallRenderer( |
| 248 "socket.setNoDelay", input_args, output_args, enter.callback())); | 248 "socket.setNoDelay", input_args, output_args, enter.callback())); |
| 249 } | 249 } |
| 250 | 250 |
| 251 int32_t GetInfo(PP_Instance instance, | 251 int32_t GetInfo(PP_Instance instance, |
| 252 PP_Var socket_id, | 252 PP_Var socket_id, |
| 253 PP_Ext_Socket_SocketInfo_Dev* result, | 253 PP_Ext_Socket_SocketInfo_Dev* result, |
| 254 PP_CompletionCallback callback) { | 254 PP_CompletionCallback callback) { |
| 255 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 255 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 256 if (enter.failed()) | 256 if (enter.failed()) |
| 257 return enter.retval(); | 257 return enter.retval(); |
| 258 | 258 |
| 259 std::vector<PP_Var> input_args; | 259 std::vector<PP_Var> input_args; |
| 260 std::vector<PP_Var*> output_args; | 260 std::vector<PP_Var*> output_args; |
| 261 input_args.push_back(socket_id); | 261 input_args.push_back(socket_id); |
| 262 output_args.push_back(result); | 262 output_args.push_back(result); |
| 263 return enter.SetResult(enter.functions()->Call( | 263 return enter.SetResult(enter.functions()->CallRenderer( |
| 264 "socket.getInfo", input_args, output_args, enter.callback())); | 264 "socket.getInfo", input_args, output_args, enter.callback())); |
| 265 } | 265 } |
| 266 | 266 |
| 267 int32_t GetNetworkList(PP_Instance instance, | 267 int32_t GetNetworkList(PP_Instance instance, |
| 268 PP_Ext_Socket_NetworkInterface_Dev_Array* result, | 268 PP_Ext_Socket_NetworkInterface_Dev_Array* result, |
| 269 PP_CompletionCallback callback) { | 269 PP_CompletionCallback callback) { |
| 270 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); | 270 EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); |
| 271 if (enter.failed()) | 271 if (enter.failed()) |
| 272 return enter.retval(); | 272 return enter.retval(); |
| 273 | 273 |
| 274 std::vector<PP_Var> input_args; | 274 std::vector<PP_Var> input_args; |
| 275 std::vector<PP_Var*> output_args; | 275 std::vector<PP_Var*> output_args; |
| 276 output_args.push_back(result); | 276 output_args.push_back(result); |
| 277 return enter.SetResult(enter.functions()->Call( | 277 return enter.SetResult(enter.functions()->CallRenderer( |
| 278 "socket.getNetworkList", input_args, output_args, enter.callback())); | 278 "socket.getNetworkList", input_args, output_args, enter.callback())); |
| 279 } | 279 } |
| 280 | 280 |
| 281 const PPB_Ext_Socket_Dev_0_1 g_ppb_ext_socket_dev_0_1_thunk = { | 281 const PPB_Ext_Socket_Dev_0_1 g_ppb_ext_socket_dev_0_1_thunk = { |
| 282 &Create, | 282 &Create, |
| 283 &Destroy, | 283 &Destroy, |
| 284 &Connect, | 284 &Connect, |
| 285 &Bind, | 285 &Bind, |
| 286 &Disconnect, | 286 &Disconnect, |
| 287 &Read, | 287 &Read, |
| 288 &Write, | 288 &Write, |
| 289 &RecvFrom, | 289 &RecvFrom, |
| 290 &SendTo, | 290 &SendTo, |
| 291 &Listen, | 291 &Listen, |
| 292 &Accept, | 292 &Accept, |
| 293 &SetKeepAlive, | 293 &SetKeepAlive, |
| 294 &SetNoDelay, | 294 &SetNoDelay, |
| 295 &GetInfo, | 295 &GetInfo, |
| 296 &GetNetworkList | 296 &GetNetworkList |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 } // namespace | 299 } // namespace |
| 300 | 300 |
| 301 const PPB_Ext_Socket_Dev_0_1* GetPPB_Ext_Socket_Dev_0_1_Thunk() { | 301 const PPB_Ext_Socket_Dev_0_1* GetPPB_Ext_Socket_Dev_0_1_Thunk() { |
| 302 return &g_ppb_ext_socket_dev_0_1_thunk; | 302 return &g_ppb_ext_socket_dev_0_1_thunk; |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace thunk | 305 } // namespace thunk |
| 306 } // namespace ppapi | 306 } // namespace ppapi |
| OLD | NEW |