OLD | NEW |
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 "native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h" |
6 | 6 |
7 #include "native_client/src/include/nacl_scoped_ptr.h" | 7 #include "native_client/src/include/nacl_scoped_ptr.h" |
8 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 8 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
9 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" | 9 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" |
10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
11 #include "native_client/src/shared/ppapi_proxy/utility.h" | 11 #include "native_client/src/shared/ppapi_proxy/utility.h" |
12 #include "native_client/src/shared/srpc/nacl_srpc.h" | 12 #include "native_client/src/shared/srpc/nacl_srpc.h" |
13 #include "ppapi/c/pp_completion_callback.h" | 13 #include "ppapi/c/pp_completion_callback.h" |
14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
16 #include "ppapi/c/dev/ppb_websocket_dev.h" | 16 #include "ppapi/c/ppb_websocket.h" |
17 #include "srpcgen/ppb_rpc.h" | 17 #include "srpcgen/ppb_rpc.h" |
18 | 18 |
19 namespace ppapi_proxy { | 19 namespace ppapi_proxy { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 PP_Resource Create(PP_Instance instance) { | 23 PP_Resource Create(PP_Instance instance) { |
24 DebugPrintf("PPB_WebSocket::Create: instance=%"NACL_PRId32"\n", instance); | 24 DebugPrintf("PPB_WebSocket::Create: instance=%"NACL_PRId32"\n", instance); |
25 | 25 |
26 PP_Resource resource; | 26 PP_Resource resource; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 if (srpc_result == NACL_SRPC_RESULT_OK) { | 261 if (srpc_result == NACL_SRPC_RESULT_OK) { |
262 PP_Var protocol = PP_MakeUndefined(); | 262 PP_Var protocol = PP_MakeUndefined(); |
263 if (DeserializeTo(protocol_bytes.get(), protocol_size, 1, &protocol)) | 263 if (DeserializeTo(protocol_bytes.get(), protocol_size, 1, &protocol)) |
264 return protocol; | 264 return protocol; |
265 } | 265 } |
266 | 266 |
267 return PP_MakeUndefined(); | 267 return PP_MakeUndefined(); |
268 } | 268 } |
269 | 269 |
270 PP_WebSocketReadyState_Dev GetReadyState(PP_Resource ws) { | 270 PP_WebSocketReadyState GetReadyState(PP_Resource ws) { |
271 DebugPrintf( | 271 DebugPrintf( |
272 "PPB_WebSocket::GetReadyState: ws=%"NACL_PRId32"\n", ws); | 272 "PPB_WebSocket::GetReadyState: ws=%"NACL_PRId32"\n", ws); |
273 | 273 |
274 int32_t ready_state; | 274 int32_t ready_state; |
275 NaClSrpcError srpc_result = | 275 NaClSrpcError srpc_result = |
276 PpbWebSocketRpcClient::PPB_WebSocket_GetReadyState( | 276 PpbWebSocketRpcClient::PPB_WebSocket_GetReadyState( |
277 GetMainSrpcChannel(), ws, &ready_state); | 277 GetMainSrpcChannel(), ws, &ready_state); |
278 DebugPrintf("PPB_WebSocket::GetReadyState: %s\n", | 278 DebugPrintf("PPB_WebSocket::GetReadyState: %s\n", |
279 NaClSrpcErrorString(srpc_result)); | 279 NaClSrpcErrorString(srpc_result)); |
280 | 280 |
281 if (srpc_result != NACL_SRPC_RESULT_OK) | 281 if (srpc_result != NACL_SRPC_RESULT_OK) |
282 return PP_WEBSOCKETREADYSTATE_INVALID_DEV; | 282 return PP_WEBSOCKETREADYSTATE_INVALID; |
283 return static_cast<PP_WebSocketReadyState_Dev>(ready_state); | 283 return static_cast<PP_WebSocketReadyState>(ready_state); |
284 } | 284 } |
285 | 285 |
286 PP_Var GetURL(PP_Resource ws) { | 286 PP_Var GetURL(PP_Resource ws) { |
287 DebugPrintf("PPB_WebSocket::GetURL: ws=%"NACL_PRId32"\n", ws); | 287 DebugPrintf("PPB_WebSocket::GetURL: ws=%"NACL_PRId32"\n", ws); |
288 | 288 |
289 nacl_abi_size_t url_size = kMaxReturnVarSize; | 289 nacl_abi_size_t url_size = kMaxReturnVarSize; |
290 nacl::scoped_array<char> url_bytes(new char[url_size]); | 290 nacl::scoped_array<char> url_bytes(new char[url_size]); |
291 NaClSrpcError srpc_result = | 291 NaClSrpcError srpc_result = |
292 PpbWebSocketRpcClient::PPB_WebSocket_GetURL( | 292 PpbWebSocketRpcClient::PPB_WebSocket_GetURL( |
293 GetMainSrpcChannel(), ws, &url_size, url_bytes.get()); | 293 GetMainSrpcChannel(), ws, &url_size, url_bytes.get()); |
294 DebugPrintf("PPB_WebSocket::GetURL: %s\n", | 294 DebugPrintf("PPB_WebSocket::GetURL: %s\n", |
295 NaClSrpcErrorString(srpc_result)); | 295 NaClSrpcErrorString(srpc_result)); |
296 | 296 |
297 if (srpc_result == NACL_SRPC_RESULT_OK) { | 297 if (srpc_result == NACL_SRPC_RESULT_OK) { |
298 PP_Var url = PP_MakeUndefined(); | 298 PP_Var url = PP_MakeUndefined(); |
299 if (DeserializeTo(url_bytes.get(), url_size, 1, &url)) | 299 if (DeserializeTo(url_bytes.get(), url_size, 1, &url)) |
300 return url; | 300 return url; |
301 } | 301 } |
302 | 302 |
303 return PP_MakeUndefined(); | 303 return PP_MakeUndefined(); |
304 } | 304 } |
305 | 305 |
306 } // namespace | 306 } // namespace |
307 | 307 |
308 const PPB_WebSocket_Dev* PluginWebSocket::GetInterface() { | 308 const PPB_WebSocket* PluginWebSocket::GetInterface() { |
309 static const PPB_WebSocket_Dev websocket_interface = { | 309 static const PPB_WebSocket websocket_interface = { |
310 &Create, | 310 &Create, |
311 &IsWebSocket, | 311 &IsWebSocket, |
312 &Connect, | 312 &Connect, |
313 &Close, | 313 &Close, |
314 &ReceiveMessage, | 314 &ReceiveMessage, |
315 &SendMessage, | 315 &SendMessage, |
316 &GetBufferedAmount, | 316 &GetBufferedAmount, |
317 &GetCloseCode, | 317 &GetCloseCode, |
318 &GetCloseReason, | 318 &GetCloseReason, |
319 &GetCloseWasClean, | 319 &GetCloseWasClean, |
320 &GetExtensions, | 320 &GetExtensions, |
321 &GetProtocol, | 321 &GetProtocol, |
322 &GetReadyState, | 322 &GetReadyState, |
323 &GetURL | 323 &GetURL |
324 }; | 324 }; |
325 return &websocket_interface; | 325 return &websocket_interface; |
326 } | 326 } |
327 | 327 |
328 } // namespace ppapi_proxy | 328 } // namespace ppapi_proxy |
OLD | NEW |