| 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 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include "native_client/src/include/nacl_macros.h" | 9 #include "native_client/src/include/nacl_macros.h" |
| 10 #include "native_client/src/include/nacl_scoped_ptr.h" | 10 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 11 #include "native_client/src/include/portability.h" | 11 #include "native_client/src/include/portability.h" |
| 12 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 12 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
| 13 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 13 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
| 14 #include "native_client/src/shared/ppapi_proxy/utility.h" | 14 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 15 #include "native_client/src/shared/srpc/nacl_srpc.h" | 15 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 16 #include "ppapi/c/ppb_url_response_info.h" | 16 #include "ppapi/c/ppb_url_response_info.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_Bool IsURLResponseInfo(PP_Resource resource) { | 23 PP_Bool IsURLResponseInfo(PP_Resource resource) { |
| 24 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: resource=%" | 24 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: resource=%" |
| 25 NACL_PRIx64"\n", resource); | 25 NACL_PRIx64"\n", resource); |
| 26 NACL_UNTESTED(); | |
| 27 | 26 |
| 28 int32_t success; | 27 int32_t success; |
| 29 NaClSrpcError srpc_result = | 28 NaClSrpcError srpc_result = |
| 30 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_IsURLResponseInfo( | 29 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_IsURLResponseInfo( |
| 31 GetMainSrpcChannel(), resource, &success); | 30 GetMainSrpcChannel(), resource, &success); |
| 32 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: %s\n", | 31 DebugPrintf("PPB_URLResponseInfo::IsURLResponseInfo: %s\n", |
| 33 NaClSrpcErrorString(srpc_result)); | 32 NaClSrpcErrorString(srpc_result)); |
| 34 | 33 |
| 35 if (srpc_result == NACL_SRPC_RESULT_OK && success) | 34 if (srpc_result == NACL_SRPC_RESULT_OK && success) |
| 36 return PP_TRUE; | 35 return PP_TRUE; |
| 37 return PP_FALSE; | 36 return PP_FALSE; |
| 38 } | 37 } |
| 39 | 38 |
| 40 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { | 39 PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { |
| 41 DebugPrintf("PPB_URLResponseInfo::GetProperty: response=%"NACL_PRIx64"\n", | 40 DebugPrintf("PPB_URLResponseInfo::GetProperty: response=%"NACL_PRIx64"\n", |
| 42 response); | 41 response); |
| 43 NACL_UNTESTED(); | |
| 44 NaClSrpcChannel* channel = GetMainSrpcChannel(); | 42 NaClSrpcChannel* channel = GetMainSrpcChannel(); |
| 45 | 43 |
| 46 PP_Var value = PP_MakeUndefined(); | 44 PP_Var value = PP_MakeUndefined(); |
| 47 nacl_abi_size_t value_size = kMaxVarSize; | 45 nacl_abi_size_t value_size = kMaxVarSize; |
| 48 nacl::scoped_array<char> value_bytes(new char[kMaxVarSize]); | 46 nacl::scoped_array<char> value_bytes(new char[kMaxVarSize]); |
| 49 | 47 |
| 50 NaClSrpcError srpc_result = | 48 NaClSrpcError srpc_result = |
| 51 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_GetProperty( | 49 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_GetProperty( |
| 52 channel, | 50 channel, |
| 53 response, | 51 response, |
| 54 static_cast<int32_t>(property), | 52 static_cast<int32_t>(property), |
| 55 &value_size, | 53 &value_size, |
| 56 value_bytes.get()); | 54 value_bytes.get()); |
| 57 DebugPrintf("PPB_URLResponseInfo::GetProperty: %s\n", | 55 DebugPrintf("PPB_URLResponseInfo::GetProperty: %s\n", |
| 58 NaClSrpcErrorString(srpc_result)); | 56 NaClSrpcErrorString(srpc_result)); |
| 59 | 57 |
| 60 if (srpc_result == NACL_SRPC_RESULT_OK) | 58 if (srpc_result == NACL_SRPC_RESULT_OK) |
| 61 (void) DeserializeTo(channel, value_bytes.get(), value_size, 1, &value); | 59 (void) DeserializeTo(channel, value_bytes.get(), value_size, 1, &value); |
| 62 return value; | 60 return value; |
| 63 } | 61 } |
| 64 | 62 |
| 65 PP_Resource GetBodyAsFileRef(PP_Resource response) { | 63 PP_Resource GetBodyAsFileRef(PP_Resource response) { |
| 66 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: response=%" | 64 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: response=%" |
| 67 NACL_PRIx64"\n", response); | 65 NACL_PRIx64"\n", response); |
| 68 NACL_UNTESTED(); | |
| 69 | 66 |
| 70 PP_Resource file_ref; | 67 PP_Resource file_ref; |
| 71 NaClSrpcError srpc_result = | 68 NaClSrpcError srpc_result = |
| 72 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_GetBodyAsFileRef( | 69 PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_GetBodyAsFileRef( |
| 73 GetMainSrpcChannel(), response, &file_ref); | 70 GetMainSrpcChannel(), response, &file_ref); |
| 74 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: %s\n", | 71 DebugPrintf("PPB_URLResponseInfo::GetBodyAsFileRef: %s\n", |
| 75 NaClSrpcErrorString(srpc_result)); | 72 NaClSrpcErrorString(srpc_result)); |
| 76 | 73 |
| 77 if (srpc_result == NACL_SRPC_RESULT_OK) | 74 if (srpc_result == NACL_SRPC_RESULT_OK) |
| 78 return file_ref; | 75 return file_ref; |
| 79 return kInvalidResourceId; | 76 return kInvalidResourceId; |
| 80 } | 77 } |
| 81 | 78 |
| 82 } // namespace | 79 } // namespace |
| 83 | 80 |
| 84 const PPB_URLResponseInfo* PluginURLResponseInfo::GetInterface() { | 81 const PPB_URLResponseInfo* PluginURLResponseInfo::GetInterface() { |
| 85 static const PPB_URLResponseInfo url_response_info_interface = { | 82 static const PPB_URLResponseInfo url_response_info_interface = { |
| 86 IsURLResponseInfo, | 83 IsURLResponseInfo, |
| 87 GetProperty, | 84 GetProperty, |
| 88 GetBodyAsFileRef, | 85 GetBodyAsFileRef, |
| 89 }; | 86 }; |
| 90 return &url_response_info_interface; | 87 return &url_response_info_interface; |
| 91 } | 88 } |
| 92 | 89 |
| 93 } // namespace ppapi_proxy | 90 } // namespace ppapi_proxy |
| OLD | NEW |