| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright 2010 The Native Client Authors. All rights reserved. | 2  * Copyright 2010 The Native Client Authors. All rights reserved. | 
| 3  * Use of this source code is governed by a BSD-style license that can | 3  * Use of this source code is governed by a BSD-style license that can | 
| 4  * be found in the LICENSE file. | 4  * be found in the LICENSE file. | 
| 5  */ | 5  */ | 
| 6 | 6 | 
| 7 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.h" | 7 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.h" | 
| 8 | 8 | 
| 9 #include <stdio.h> | 9 #include <stdio.h> | 
| 10 #include <string.h> | 10 #include <string.h> | 
| 11 #include "native_client/src/include/nacl_macros.h" | 11 #include "native_client/src/include/nacl_macros.h" | 
| 12 #include "native_client/src/include/nacl_scoped_ptr.h" | 12 #include "native_client/src/include/nacl_scoped_ptr.h" | 
| 13 #include "native_client/src/include/portability.h" | 13 #include "native_client/src/include/portability.h" | 
| 14 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 14 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 
| 15 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 15 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 
| 16 #include "native_client/src/shared/ppapi_proxy/utility.h" | 16 #include "native_client/src/shared/ppapi_proxy/utility.h" | 
| 17 #include "native_client/src/shared/srpc/nacl_srpc.h" | 17 #include "native_client/src/shared/srpc/nacl_srpc.h" | 
| 18 #include "ppapi/c/ppb_url_request_info.h" | 18 #include "ppapi/c/ppb_url_request_info.h" | 
| 19 #include "srpcgen/ppb_rpc.h" | 19 #include "srpcgen/ppb_rpc.h" | 
| 20 | 20 | 
| 21 namespace ppapi_proxy { | 21 namespace ppapi_proxy { | 
| 22 | 22 | 
| 23 namespace { | 23 namespace { | 
| 24 | 24 | 
| 25 PP_Resource Create(PP_Module module) { | 25 PP_Resource Create(PP_Module module) { | 
| 26   DebugPrintf("PPB_URLRequestInfo::Create: module=%" | 26   DebugPrintf("PPB_URLRequestInfo::Create: module=%"NACL_PRIx64"\n", module); | 
| 27               NACL_PRIx64"\n", module); |  | 
| 28   NACL_UNTESTED(); |  | 
| 29 | 27 | 
| 30   PP_Resource resource; | 28   PP_Resource resource; | 
| 31   NaClSrpcError srpc_result = | 29   NaClSrpcError srpc_result = | 
| 32       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_Create( | 30       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_Create( | 
| 33           GetMainSrpcChannel(), module, &resource); | 31           GetMainSrpcChannel(), module, &resource); | 
| 34   DebugPrintf("PPB_URLRequestInfo::Create: %s\n", | 32   DebugPrintf("PPB_URLRequestInfo::Create: %s\n", | 
| 35               NaClSrpcErrorString(srpc_result)); | 33               NaClSrpcErrorString(srpc_result)); | 
| 36 | 34 | 
| 37   if (srpc_result == NACL_SRPC_RESULT_OK) | 35   if (srpc_result == NACL_SRPC_RESULT_OK) | 
| 38     return static_cast<PP_Resource>(resource); | 36     return resource; | 
| 39   return kInvalidResourceId; | 37   return kInvalidResourceId; | 
| 40 } | 38 } | 
| 41 | 39 | 
| 42 PP_Bool IsURLRequestInfo(PP_Resource resource) { | 40 PP_Bool IsURLRequestInfo(PP_Resource resource) { | 
| 43   DebugPrintf("PPB_URLRequestInfo::IsURLRequestInfo: resource=%"NACL_PRIx64"\n", | 41   DebugPrintf("PPB_URLRequestInfo::IsURLRequestInfo: resource=%"NACL_PRIx64"\n", | 
| 44               resource); | 42               resource); | 
| 45   NACL_UNTESTED(); |  | 
| 46 | 43 | 
| 47   int32_t success; | 44   int32_t success; | 
| 48   NaClSrpcError srpc_result = | 45   NaClSrpcError srpc_result = | 
| 49       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_IsURLRequestInfo( | 46       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_IsURLRequestInfo( | 
| 50           GetMainSrpcChannel(), resource, &success); | 47           GetMainSrpcChannel(), resource, &success); | 
| 51   DebugPrintf("PPB_URLRequestInfo::IsURLRequestInfo: %s\n", | 48   DebugPrintf("PPB_URLRequestInfo::IsURLRequestInfo: %s\n", | 
| 52               NaClSrpcErrorString(srpc_result)); | 49               NaClSrpcErrorString(srpc_result)); | 
| 53 | 50 | 
| 54   if (srpc_result == NACL_SRPC_RESULT_OK && success) | 51   if (srpc_result == NACL_SRPC_RESULT_OK && success) | 
| 55     return PP_TRUE; | 52     return PP_TRUE; | 
| 56   return PP_FALSE; | 53   return PP_FALSE; | 
| 57 } | 54 } | 
| 58 | 55 | 
| 59 PP_Bool SetProperty(PP_Resource request, | 56 PP_Bool SetProperty(PP_Resource request, | 
| 60                     PP_URLRequestProperty property, | 57                     PP_URLRequestProperty property, | 
| 61                     struct PP_Var value) { | 58                     struct PP_Var value) { | 
| 62   DebugPrintf("PPB_URLRequestInfo::SetProperty: request=%"NACL_PRIx64"\n", | 59   DebugPrintf("PPB_URLRequestInfo::SetProperty: request=%"NACL_PRIx64"\n", | 
| 63               request); | 60               request); | 
| 64   NACL_UNTESTED(); |  | 
| 65 | 61 | 
| 66   nacl_abi_size_t value_size = kMaxVarSize; | 62   nacl_abi_size_t value_size = kMaxVarSize; | 
| 67   nacl::scoped_array<char> value_bytes(Serialize(&value, 1, &value_size)); | 63   nacl::scoped_array<char> value_bytes(Serialize(&value, 1, &value_size)); | 
| 68 | 64 | 
| 69   int32_t success; | 65   int32_t success; | 
| 70   NaClSrpcError srpc_result = | 66   NaClSrpcError srpc_result = | 
| 71       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_SetProperty( | 67       PpbURLRequestInfoRpcClient::PPB_URLRequestInfo_SetProperty( | 
| 72           GetMainSrpcChannel(), | 68           GetMainSrpcChannel(), | 
| 73           request, | 69           request, | 
| 74           static_cast<int32_t>(property), | 70           static_cast<int32_t>(property), | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 138     Create, | 134     Create, | 
| 139     IsURLRequestInfo, | 135     IsURLRequestInfo, | 
| 140     SetProperty, | 136     SetProperty, | 
| 141     AppendDataToBody, | 137     AppendDataToBody, | 
| 142     AppendFileToBody, | 138     AppendFileToBody, | 
| 143   }; | 139   }; | 
| 144   return &url_request_info_interface; | 140   return &url_request_info_interface; | 
| 145 } | 141 } | 
| 146 | 142 | 
| 147 }  // namespace ppapi_proxy | 143 }  // namespace ppapi_proxy | 
| OLD | NEW | 
|---|