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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.cc

Issue 9192009: WebSocket Pepper API: make the API out of dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove binary type handling interfaces Created 8 years, 11 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
OLDNEW
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
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 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* PluginWebSocket::GetInterface() {
345 static const PPB_WebSocket_Dev websocket_interface = { 309 static const PPB_WebSocket 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698