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_URLRequestInfo functions. | 5 // SRPC-abstraction wrappers around PPB_URLRequestInfo 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/shared/ppapi_proxy/browser_globals.h" | 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
10 #include "ppapi/c/ppb_url_request_info.h" | 10 #include "ppapi/c/ppb_url_request_info.h" |
11 #include "srpcgen/ppb_rpc.h" | 11 #include "srpcgen/ppb_rpc.h" |
12 | 12 |
13 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_Create( | 13 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_Create( |
14 NaClSrpcRpc* rpc, | 14 NaClSrpcRpc* rpc, |
15 NaClSrpcClosure* done, | 15 NaClSrpcClosure* done, |
16 // inputs | 16 // inputs |
17 int64_t module, | 17 PP_Module module, |
18 // outputs | 18 // outputs |
19 int64_t* resource) { | 19 PP_Resource* resource) { |
20 NACL_UNTESTED(); | 20 NACL_UNTESTED(); |
21 NaClSrpcClosureRunner runner(done); | 21 NaClSrpcClosureRunner runner(done); |
22 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 22 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
23 | 23 |
24 PP_Resource pp_resource = | 24 *resource = |
25 ppapi_proxy::PPBURLRequestInfoInterface()->Create( | 25 ppapi_proxy::PPBURLRequestInfoInterface()->Create(module); |
26 static_cast<PP_Module>(module)); | |
27 | 26 |
28 *resource = static_cast<int64_t>(pp_resource); | |
29 rpc->result = NACL_SRPC_RESULT_OK; | 27 rpc->result = NACL_SRPC_RESULT_OK; |
30 } | 28 } |
31 | 29 |
32 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_IsURLRequestInfo( | 30 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_IsURLRequestInfo( |
33 NaClSrpcRpc* rpc, | 31 NaClSrpcRpc* rpc, |
34 NaClSrpcClosure* done, | 32 NaClSrpcClosure* done, |
35 // inputs | 33 // inputs |
36 int64_t resource, | 34 PP_Resource resource, |
37 // outputs | 35 // outputs |
38 int32_t* is_url_request_info) { | 36 int32_t* is_url_request_info) { |
39 NACL_UNTESTED(); | 37 NACL_UNTESTED(); |
40 NaClSrpcClosureRunner runner(done); | 38 NaClSrpcClosureRunner runner(done); |
41 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 39 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
42 | 40 |
43 PP_Bool pp_is_url_request_info = | 41 PP_Bool pp_is_url_request_info = |
44 ppapi_proxy::PPBURLRequestInfoInterface()->IsURLRequestInfo( | 42 ppapi_proxy::PPBURLRequestInfoInterface()->IsURLRequestInfo(resource); |
45 static_cast<PP_Resource>(resource)); | |
46 | 43 |
47 *is_url_request_info = (pp_is_url_request_info == PP_TRUE); | 44 *is_url_request_info = (pp_is_url_request_info == PP_TRUE); |
48 rpc->result = NACL_SRPC_RESULT_OK; | 45 rpc->result = NACL_SRPC_RESULT_OK; |
49 } | 46 } |
50 | 47 |
51 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_SetProperty( | 48 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_SetProperty( |
52 NaClSrpcRpc* rpc, | 49 NaClSrpcRpc* rpc, |
53 NaClSrpcClosure* done, | 50 NaClSrpcClosure* done, |
54 // inputs | 51 // inputs |
55 int64_t request, | 52 PP_Resource request, |
56 int32_t property, | 53 int32_t property, |
57 nacl_abi_size_t value_size, char* value_bytes, | 54 nacl_abi_size_t value_size, char* value_bytes, |
58 // outputs | 55 // outputs |
59 int32_t* success) { | 56 int32_t* success) { |
60 NACL_UNTESTED(); | 57 NACL_UNTESTED(); |
61 NaClSrpcClosureRunner runner(done); | 58 NaClSrpcClosureRunner runner(done); |
62 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 59 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
63 | 60 |
64 PP_Var value; | 61 PP_Var value; |
65 if (!ppapi_proxy::DeserializeTo( | 62 if (!ppapi_proxy::DeserializeTo( |
66 rpc->channel, value_bytes, value_size, 1, &value)) | 63 rpc->channel, value_bytes, value_size, 1, &value)) |
67 return; | 64 return; |
68 | 65 |
69 PP_Bool pp_success = | 66 PP_Bool pp_success = |
70 ppapi_proxy::PPBURLRequestInfoInterface()->SetProperty( | 67 ppapi_proxy::PPBURLRequestInfoInterface()->SetProperty( |
71 static_cast<PP_Resource>(request), | 68 request, |
72 static_cast<PP_URLRequestProperty>(property), | 69 static_cast<PP_URLRequestProperty>(property), |
73 value); | 70 value); |
74 | 71 |
75 *success = (pp_success == PP_TRUE); | 72 *success = (pp_success == PP_TRUE); |
76 rpc->result = NACL_SRPC_RESULT_OK; | 73 rpc->result = NACL_SRPC_RESULT_OK; |
77 } | 74 } |
78 | 75 |
79 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_AppendDataToBody( | 76 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_AppendDataToBody( |
80 NaClSrpcRpc* rpc, | 77 NaClSrpcRpc* rpc, |
81 NaClSrpcClosure* done, | 78 NaClSrpcClosure* done, |
82 // inputs | 79 // inputs |
83 int64_t request, | 80 PP_Resource request, |
84 nacl_abi_size_t data_size, char* data_bytes, | 81 nacl_abi_size_t data_size, char* data_bytes, |
85 // outputs | 82 // outputs |
86 int32_t* success) { | 83 int32_t* success) { |
87 NACL_UNTESTED(); | 84 NACL_UNTESTED(); |
88 NaClSrpcClosureRunner runner(done); | 85 NaClSrpcClosureRunner runner(done); |
89 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 86 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
90 | 87 |
91 PP_Bool pp_success = | 88 PP_Bool pp_success = |
92 ppapi_proxy::PPBURLRequestInfoInterface()->AppendDataToBody( | 89 ppapi_proxy::PPBURLRequestInfoInterface()->AppendDataToBody( |
93 static_cast<PP_Resource>(request), | 90 request, |
94 static_cast<const char*>(data_bytes), | 91 static_cast<const char*>(data_bytes), |
95 static_cast<uint32_t>(data_size)); | 92 static_cast<uint32_t>(data_size)); |
96 | 93 |
97 *success = (pp_success == PP_TRUE); | 94 *success = (pp_success == PP_TRUE); |
98 rpc->result = NACL_SRPC_RESULT_OK; | 95 rpc->result = NACL_SRPC_RESULT_OK; |
99 } | 96 } |
100 | 97 |
101 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_AppendFileToBody( | 98 void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_AppendFileToBody( |
102 NaClSrpcRpc* rpc, | 99 NaClSrpcRpc* rpc, |
103 NaClSrpcClosure* done, | 100 NaClSrpcClosure* done, |
104 // inputs | 101 // inputs |
105 int64_t request, | 102 PP_Resource request, |
106 int64_t file_ref, | 103 PP_Resource file_ref, |
107 int64_t start_offset, | 104 int64_t start_offset, |
108 int64_t number_of_bytes, | 105 int64_t number_of_bytes, |
109 double expected_last_modified_time, | 106 double expected_last_modified_time, |
110 // outputs | 107 // outputs |
111 int32_t* success) { | 108 int32_t* success) { |
112 NACL_UNTESTED(); | 109 NACL_UNTESTED(); |
113 NaClSrpcClosureRunner runner(done); | 110 NaClSrpcClosureRunner runner(done); |
114 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 111 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
115 | 112 |
116 PP_Bool pp_success = | 113 PP_Bool pp_success = |
117 ppapi_proxy::PPBURLRequestInfoInterface()->AppendFileToBody( | 114 ppapi_proxy::PPBURLRequestInfoInterface()->AppendFileToBody( |
118 static_cast<PP_Resource>(request), | 115 request, |
119 static_cast<PP_Resource>(file_ref), | 116 file_ref, |
120 start_offset, | 117 start_offset, |
121 number_of_bytes, | 118 number_of_bytes, |
122 static_cast<PP_Time>(expected_last_modified_time)); | 119 static_cast<PP_Time>(expected_last_modified_time)); |
123 | 120 |
124 *success = (pp_success == PP_TRUE); | 121 *success = (pp_success == PP_TRUE); |
125 rpc->result = NACL_SRPC_RESULT_OK; | 122 rpc->result = NACL_SRPC_RESULT_OK; |
126 } | 123 } |
OLD | NEW |