OLD | NEW |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 PPP_Printing functions. | 5 // SRPC-abstraction wrappers around PPP_Printing functions. |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "native_client/src/include/portability.h" | 9 #include "native_client/src/include/portability.h" |
10 #include "native_client/src/include/portability_process.h" | 10 #include "native_client/src/include/portability_process.h" |
11 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 11 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
12 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 12 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
| 13 #include "native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h" |
13 #include "native_client/src/shared/ppapi_proxy/utility.h" | 14 #include "native_client/src/shared/ppapi_proxy/utility.h" |
14 #include "native_client/src/third_party/ppapi/c/dev/ppp_printing_dev.h" | 15 #include "native_client/src/third_party/ppapi/c/dev/ppp_printing_dev.h" |
15 #include "native_client/src/third_party/ppapi/c/pp_resource.h" | 16 #include "native_client/src/third_party/ppapi/c/pp_resource.h" |
16 #include "native_client/src/third_party/ppapi/c/ppp.h" | 17 #include "native_client/src/third_party/ppapi/c/ppp.h" |
17 #include "srpcgen/ppp_rpc.h" | |
18 | 18 |
19 using ppapi_proxy::DebugPrintf; | 19 using ppapi_proxy::DebugPrintf; |
20 using ppapi_proxy::PPPPrintingInterface; | 20 using ppapi_proxy::PPPPrintingInterface; |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const nacl_abi_size_t kPPPrintOutputFormatBytes = | |
25 static_cast<nacl_abi_size_t>(sizeof(PP_PrintOutputFormat_Dev)); | |
26 const nacl_abi_size_t kPPPrintSettingsBytes = | 24 const nacl_abi_size_t kPPPrintSettingsBytes = |
27 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); | 25 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); |
28 const nacl_abi_size_t kPPPrintPageNumberRangeBytes = | 26 const nacl_abi_size_t kPPPrintPageNumberRangeBytes = |
29 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); | 27 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); |
30 | 28 |
31 } // namespace | 29 } // namespace |
32 | 30 |
33 void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats( | 31 void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats( |
34 NaClSrpcRpc* rpc, | 32 NaClSrpcRpc* rpc, |
35 NaClSrpcClosure* done, | 33 NaClSrpcClosure* done, |
36 // inputs | 34 // inputs |
37 PP_Instance instance, | 35 PP_Instance instance, |
38 // outputs | 36 // outputs |
39 nacl_abi_size_t* formats_bytes, char* formats, | 37 int32_t* formats) { |
40 int32_t* format_count) { | |
41 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 38 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
42 NaClSrpcClosureRunner runner(done); | 39 NaClSrpcClosureRunner runner(done); |
43 | 40 |
44 PP_PrintOutputFormat_Dev* pp_formats = | 41 uint32_t pp_formats = PPPPrintingInterface()->QuerySupportedFormats(instance); |
45 PPPPrintingInterface()->QuerySupportedFormats( | 42 *formats = static_cast<int32_t>(pp_formats); |
46 instance, | |
47 reinterpret_cast<uint32_t*>(format_count)); | |
48 if (pp_formats != NULL) { | |
49 nacl_abi_size_t formats_bytes_needed = | |
50 *format_count * kPPPrintOutputFormatBytes; | |
51 if (*formats_bytes >= formats_bytes_needed) { | |
52 *formats_bytes = formats_bytes_needed; | |
53 memcpy(pp_formats, formats, formats_bytes_needed); | |
54 } else { | |
55 *format_count = 0; | |
56 } | |
57 ppapi_proxy::PPBMemoryInterface()->MemFree(pp_formats); | |
58 } | |
59 | 43 |
60 DebugPrintf("PPP_Printing::QuerySupportedFormats: " | 44 DebugPrintf("PPP_Printing::QuerySupportedFormats: " |
61 "format_count=%"NACL_PRId32"\n", *format_count); | 45 "formats=%"NACL_PRId32"\n", *formats); |
62 rpc->result = NACL_SRPC_RESULT_OK; | 46 rpc->result = NACL_SRPC_RESULT_OK; |
63 } | 47 } |
64 | 48 |
65 void PppPrintingRpcServer::PPP_Printing_Begin( | 49 void PppPrintingRpcServer::PPP_Printing_Begin( |
66 NaClSrpcRpc* rpc, | 50 NaClSrpcRpc* rpc, |
67 NaClSrpcClosure* done, | 51 NaClSrpcClosure* done, |
68 // inputs | 52 // inputs |
69 PP_Instance instance, | 53 PP_Instance instance, |
70 nacl_abi_size_t print_settings_bytes, char* print_settings, | 54 nacl_abi_size_t print_settings_bytes, char* print_settings, |
71 // outputs | 55 // outputs |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // inputs | 99 // inputs |
116 PP_Instance instance) { | 100 PP_Instance instance) { |
117 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 101 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
118 NaClSrpcClosureRunner runner(done); | 102 NaClSrpcClosureRunner runner(done); |
119 | 103 |
120 PPPPrintingInterface()->End(instance); | 104 PPPPrintingInterface()->End(instance); |
121 | 105 |
122 DebugPrintf("PPP_Printing::End\n"); | 106 DebugPrintf("PPP_Printing::End\n"); |
123 rpc->result = NACL_SRPC_RESULT_OK; | 107 rpc->result = NACL_SRPC_RESULT_OK; |
124 } | 108 } |
OLD | NEW |