| OLD | NEW |
| 1 // Copyright 2010 The Native Client Authors. All rights reserved. | 1 // Copyright 2010 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can | 2 // Use of this source code is governed by a BSD-style license that can |
| 3 // be found in the LICENSE file. | 3 // be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // SRPC-abstraction wrappers around PPB_URLResponseInfo functions. | 5 // SRPC-abstraction wrappers around PPB_URLResponseInfo functions. |
| 6 | 6 |
| 7 #include "native_client/src/include/nacl_macros.h" | 7 #include "native_client/src/include/nacl_macros.h" |
| 8 #include "native_client/src/include/portability.h" | 8 #include "native_client/src/include/portability.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" |
| 11 #include "native_client/src/shared/ppapi_proxy/utility.h" | 11 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 12 #include "ppapi/c/ppb_url_response_info.h" | 12 #include "ppapi/c/ppb_url_response_info.h" |
| 13 #include "srpcgen/ppb_rpc.h" | 13 #include "srpcgen/ppb_rpc.h" |
| 14 | 14 |
| 15 using ppapi_proxy::PPBURLResponseInfoInterface; | 15 using ppapi_proxy::PPBURLResponseInfoInterface; |
| 16 using ppapi_proxy::SerializeTo; | 16 using ppapi_proxy::SerializeTo; |
| 17 using ppapi_proxy::DebugPrintf; | 17 using ppapi_proxy::DebugPrintf; |
| 18 | 18 |
| 19 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_IsURLResponseInfo( | 19 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_IsURLResponseInfo( |
| 20 NaClSrpcRpc* rpc, | 20 NaClSrpcRpc* rpc, |
| 21 NaClSrpcClosure* done, | 21 NaClSrpcClosure* done, |
| 22 // inputs | 22 // inputs |
| 23 PP_Resource resource, | 23 PP_Resource resource, |
| 24 // outputs | 24 // outputs |
| 25 int32_t* success) { | 25 int32_t* success) { |
| 26 NACL_UNTESTED(); | |
| 27 NaClSrpcClosureRunner runner(done); | 26 NaClSrpcClosureRunner runner(done); |
| 28 | 27 |
| 29 PP_Bool pp_success = | 28 PP_Bool pp_success = |
| 30 PPBURLResponseInfoInterface()->IsURLResponseInfo(resource); | 29 PPBURLResponseInfoInterface()->IsURLResponseInfo(resource); |
| 31 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: pp_success=%d\n", | 30 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: pp_success=%d\n", |
| 32 pp_success); | 31 pp_success); |
| 33 | 32 |
| 34 *success = (pp_success == PP_TRUE); | 33 *success = (pp_success == PP_TRUE); |
| 35 rpc->result = NACL_SRPC_RESULT_OK; | 34 rpc->result = NACL_SRPC_RESULT_OK; |
| 36 } | 35 } |
| 37 | 36 |
| 38 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_GetProperty( | 37 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_GetProperty( |
| 39 NaClSrpcRpc* rpc, | 38 NaClSrpcRpc* rpc, |
| 40 NaClSrpcClosure* done, | 39 NaClSrpcClosure* done, |
| 41 // inputs | 40 // inputs |
| 42 PP_Resource response, | 41 PP_Resource response, |
| 43 int32_t property, | 42 int32_t property, |
| 44 // outputs | 43 // outputs |
| 45 nacl_abi_size_t* value_size, char* value_bytes) { | 44 nacl_abi_size_t* value_size, char* value_bytes) { |
| 46 NACL_UNTESTED(); | |
| 47 NaClSrpcClosureRunner runner(done); | 45 NaClSrpcClosureRunner runner(done); |
| 48 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 46 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 49 | 47 |
| 50 PP_Var value = PPBURLResponseInfoInterface()->GetProperty( | 48 PP_Var value = PPBURLResponseInfoInterface()->GetProperty( |
| 51 response, | 49 response, static_cast<PP_URLResponseProperty>(property)); |
| 52 static_cast<PP_URLResponseProperty>(property)); | |
| 53 DebugPrintf("PPB_URLResponseInfo::GetProperty: type=%d\n", | 50 DebugPrintf("PPB_URLResponseInfo::GetProperty: type=%d\n", |
| 54 value.type); | 51 value.type); |
| 55 | 52 |
| 56 if (!SerializeTo(&value, value_bytes, value_size)) | 53 if (!SerializeTo(&value, value_bytes, value_size)) |
| 57 return; | 54 return; |
| 58 rpc->result = NACL_SRPC_RESULT_OK; | 55 rpc->result = NACL_SRPC_RESULT_OK; |
| 59 } | 56 } |
| 60 | 57 |
| 61 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_GetBodyAsFileRef( | 58 void PpbURLResponseInfoRpcServer::PPB_URLResponseInfo_GetBodyAsFileRef( |
| 62 NaClSrpcRpc* rpc, | 59 NaClSrpcRpc* rpc, |
| 63 NaClSrpcClosure* done, | 60 NaClSrpcClosure* done, |
| 64 // inputs | 61 // inputs |
| 65 PP_Resource response, | 62 PP_Resource response, |
| 66 // outputs | 63 // outputs |
| 67 PP_Resource* file_ref) { | 64 PP_Resource* file_ref) { |
| 68 NACL_UNTESTED(); | |
| 69 NaClSrpcClosureRunner runner(done); | 65 NaClSrpcClosureRunner runner(done); |
| 70 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 66 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 71 | 67 |
| 72 *file_ref = PPBURLResponseInfoInterface()->GetBodyAsFileRef(response); | 68 *file_ref = PPBURLResponseInfoInterface()->GetBodyAsFileRef(response); |
| 73 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: file_ref="NACL_PRIx64"\n", | 69 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: file_ref="NACL_PRIx64"\n", |
| 74 *file_ref); | 70 *file_ref); |
| 75 | 71 |
| 76 rpc->result = NACL_SRPC_RESULT_OK; | 72 rpc->result = NACL_SRPC_RESULT_OK; |
| 77 } | 73 } |
| OLD | NEW |