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" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PP_Bool SetBinaryType(PP_Resource ws, | |
307 PP_WebSocketBinaryType_Dev binary_type) { | |
308 DebugPrintf("PPB_WebSocket::SetBinaryType: ws=%"NACL_PRId32"\n", ws); | |
309 | |
310 int32_t success; | |
311 NaClSrpcError srpc_result = | |
312 PpbWebSocketRpcClient::PPB_WebSocket_SetBinaryType( | |
313 GetMainSrpcChannel(), | |
314 ws, | |
315 static_cast<int32_t>(binary_type), | |
316 &success); | |
317 DebugPrintf("PPB_WebSocket::SetBinaryType: %s\n", | |
318 NaClSrpcErrorString(srpc_result)); | |
319 | |
320 if (srpc_result == NACL_SRPC_RESULT_OK && success) | |
321 return PP_TRUE; | |
322 return PP_FALSE; | |
323 } | |
324 | |
325 PP_WebSocketBinaryType_Dev GetBinaryType(PP_Resource ws) { | |
326 DebugPrintf("PPB_WebSocket::GetBinaryType: ws=%"NACL_PRId32"\n", ws); | |
327 | |
328 int32_t binary_type; | |
329 NaClSrpcError srpc_result = | |
330 PpbWebSocketRpcClient::PPB_WebSocket_GetBinaryType( | |
331 GetMainSrpcChannel(), | |
332 ws, | |
333 &binary_type); | |
334 DebugPrintf("PPB_WebSocket::GetBinaryType: %s\n", | |
335 NaClSrpcErrorString(srpc_result)); | |
336 | |
337 if (srpc_result != NACL_SRPC_RESULT_OK) | |
338 return PP_WEBSOCKETBINARYTYPE_INVALID; | |
339 return static_cast<PP_WebSocketBinaryType_Dev>(binary_type); | |
340 } | |
341 | |
342 } // namespace | 306 } // namespace |
343 | 307 |
344 const PPB_WebSocket_Dev* PluginWebSocket::GetInterface() { | 308 const PPB_WebSocket_Dev* PluginWebSocket::GetInterface() { |
345 static const PPB_WebSocket_Dev websocket_interface = { | 309 static const PPB_WebSocket_Dev websocket_interface = { |
346 &Create, | 310 &Create, |
347 &IsWebSocket, | 311 &IsWebSocket, |
348 &Connect, | 312 &Connect, |
349 &Close, | 313 &Close, |
350 &ReceiveMessage, | 314 &ReceiveMessage, |
351 &SendMessage, | 315 &SendMessage, |
352 &GetBufferedAmount, | 316 &GetBufferedAmount, |
353 &GetCloseCode, | 317 &GetCloseCode, |
354 &GetCloseReason, | 318 &GetCloseReason, |
355 &GetCloseWasClean, | 319 &GetCloseWasClean, |
356 &GetExtensions, | 320 &GetExtensions, |
357 &GetProtocol, | 321 &GetProtocol, |
358 &GetReadyState, | 322 &GetReadyState, |
359 &GetURL, | 323 &GetURL |
360 &SetBinaryType, | |
361 &GetBinaryType | |
362 }; | 324 }; |
363 return &websocket_interface; | 325 return &websocket_interface; |
364 } | 326 } |
365 | 327 |
366 } // namespace ppapi_proxy | 328 } // namespace ppapi_proxy |
OLD | NEW |