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 // SRPC-abstraction wrappers around PPB_WebSocket functions. | 5 // SRPC-abstraction wrappers around PPB_WebSocket functions. |
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/browser_callback.h" | 8 #include "native_client/src/shared/ppapi_proxy/browser_callback.h" |
9 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 9 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
10 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 10 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // outputs | 137 // outputs |
138 int32_t* pp_error) { | 138 int32_t* pp_error) { |
139 NaClSrpcClosureRunner runner(done); | 139 NaClSrpcClosureRunner runner(done); |
140 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 140 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
141 | 141 |
142 PP_Var* callback_var = NULL; | 142 PP_Var* callback_var = NULL; |
143 PP_CompletionCallback remote_callback = | 143 PP_CompletionCallback remote_callback = |
144 MakeRemoteCompletionCallback(rpc->channel, callback_id, &callback_var); | 144 MakeRemoteCompletionCallback(rpc->channel, callback_id, &callback_var); |
145 if (NULL == remote_callback.func) | 145 if (NULL == remote_callback.func) |
146 return; | 146 return; |
| 147 // TODO(toyoshim): Removing optional flag is easy way to expect asynchronous |
| 148 // completion on the following PPBWebSocketInterface()->ReceiveMessage(). But |
| 149 // from the viewpoint of performance, we should handle synchronous |
| 150 // completion correctly. |
| 151 remote_callback.flags &= ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL; |
147 | 152 |
148 // The callback is always invoked asynchronously for now, so it doesn't care | 153 // The callback is always invoked asynchronously for now, so it doesn't care |
149 // about re-entrancy. | 154 // about re-entrancy. |
150 *pp_error = PPBWebSocketInterface()->ReceiveMessage( | 155 *pp_error = PPBWebSocketInterface()->ReceiveMessage( |
151 ws, callback_var, remote_callback); | 156 ws, callback_var, remote_callback); |
152 DebugPrintf("PPB_WebSocket::ReceiveMessage: pp_error=%"NACL_PRId32"\n", | 157 DebugPrintf("PPB_WebSocket::ReceiveMessage: pp_error=%"NACL_PRId32"\n", |
153 *pp_error); | 158 *pp_error); |
154 | 159 CHECK(*pp_error != PP_OK); // Should not complete synchronously |
155 if (*pp_error != PP_OK_COMPLETIONPENDING) | 160 if (*pp_error != PP_OK_COMPLETIONPENDING) |
156 DeleteRemoteCallbackInfo(remote_callback); | 161 DeleteRemoteCallbackInfo(remote_callback); |
157 rpc->result = NACL_SRPC_RESULT_OK; | 162 rpc->result = NACL_SRPC_RESULT_OK; |
158 } | 163 } |
159 | 164 |
160 void PpbWebSocketRpcServer::PPB_WebSocket_SendMessage( | 165 void PpbWebSocketRpcServer::PPB_WebSocket_SendMessage( |
161 NaClSrpcRpc* rpc, | 166 NaClSrpcRpc* rpc, |
162 NaClSrpcClosure* done, | 167 NaClSrpcClosure* done, |
163 // inputs | 168 // inputs |
164 PP_Resource ws, | 169 PP_Resource ws, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 char* url_bytes) { | 319 char* url_bytes) { |
315 NaClSrpcClosureRunner runner(done); | 320 NaClSrpcClosureRunner runner(done); |
316 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 321 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
317 | 322 |
318 PP_Var url = PPBWebSocketInterface()->GetURL(ws); | 323 PP_Var url = PPBWebSocketInterface()->GetURL(ws); |
319 DebugPrintf("PPB_WebSocket::GetURL:: url.type=%d\n", url.type); | 324 DebugPrintf("PPB_WebSocket::GetURL:: url.type=%d\n", url.type); |
320 | 325 |
321 if (SerializeTo(&url, url_bytes, url_size)) | 326 if (SerializeTo(&url, url_bytes, url_size)) |
322 rpc->result = NACL_SRPC_RESULT_OK; | 327 rpc->result = NACL_SRPC_RESULT_OK; |
323 } | 328 } |
OLD | NEW |