Index: src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc |
diff --git a/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc b/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc |
index 7ac00865d61a1148e6700cb04cb83fcad2533095..fd8e911a141678a9c7397d4e757c4d03beddc955 100644 |
--- a/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc |
+++ b/src/shared/ppapi_proxy/plugin_ppp_printing_rpc_server.cc |
@@ -9,25 +9,30 @@ |
#include "native_client/src/include/portability.h" |
#include "native_client/src/include/portability_process.h" |
#include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
-#include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
+#include "native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h" |
elijahtaylor (use chromium)
2011/08/24 20:08:23
Same comment
|
#include "native_client/src/shared/ppapi_proxy/utility.h" |
#include "native_client/src/third_party/ppapi/c/dev/ppp_printing_dev.h" |
#include "native_client/src/third_party/ppapi/c/pp_resource.h" |
#include "native_client/src/third_party/ppapi/c/ppp.h" |
-#include "srpcgen/ppp_rpc.h" |
using ppapi_proxy::DebugPrintf; |
-using ppapi_proxy::PPPPrintingInterface; |
namespace { |
-const nacl_abi_size_t kPPPrintOutputFormatBytes = |
- static_cast<nacl_abi_size_t>(sizeof(PP_PrintOutputFormat_Dev)); |
const nacl_abi_size_t kPPPrintSettingsBytes = |
static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); |
const nacl_abi_size_t kPPPrintPageNumberRangeBytes = |
static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); |
+const PPP_Printing_Dev* PPPPrinting() { |
+ static const PPP_Printing_Dev* ppp_printing = NULL; |
+ if (ppp_printing == NULL) { |
+ ppp_printing = reinterpret_cast<const PPP_Printing_Dev*>( |
+ ::PPP_GetInterface(PPP_PRINTING_DEV_INTERFACE)); |
+ } |
+ return ppp_printing; |
+} |
elijahtaylor (use chromium)
2011/08/24 20:08:23
It looks like this is normally implemented in plug
|
+ |
} // namespace |
void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats( |
@@ -36,29 +41,18 @@ void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats( |
// inputs |
PP_Instance instance, |
// outputs |
- nacl_abi_size_t* formats_bytes, char* formats, |
- int32_t* format_count) { |
+ int32_t* formats) { |
rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
NaClSrpcClosureRunner runner(done); |
- PP_PrintOutputFormat_Dev* pp_formats = |
- PPPPrintingInterface()->QuerySupportedFormats( |
- instance, |
- reinterpret_cast<uint32_t*>(format_count)); |
- if (pp_formats != NULL) { |
- nacl_abi_size_t formats_bytes_needed = |
- *format_count * kPPPrintOutputFormatBytes; |
- if (*formats_bytes >= formats_bytes_needed) { |
- *formats_bytes = formats_bytes_needed; |
- memcpy(pp_formats, formats, formats_bytes_needed); |
- } else { |
- *format_count = 0; |
- } |
- ppapi_proxy::PPBMemoryInterface()->MemFree(pp_formats); |
- } |
+ const PPP_Printing_Dev* ppp_printing = PPPPrinting(); |
+ if (ppp_printing == NULL || ppp_printing->QuerySupportedFormats == NULL) |
+ return; |
+ uint32_t pp_formats = ppp_printing->QuerySupportedFormats(instance); |
+ *formats = static_cast<int32_t>(pp_formats); |
DebugPrintf("PPP_Printing::QuerySupportedFormats: " |
- "format_count=%"NACL_PRId32"\n", *format_count); |
+ "formats=%"NACL_PRId32"\n", *formats); |
rpc->result = NACL_SRPC_RESULT_OK; |
} |
@@ -73,11 +67,14 @@ void PppPrintingRpcServer::PPP_Printing_Begin( |
rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
NaClSrpcClosureRunner runner(done); |
+ const PPP_Printing_Dev* ppp_printing = PPPPrinting(); |
+ if (ppp_printing == NULL || ppp_printing->Begin == NULL) |
elijahtaylor (use chromium)
2011/08/24 20:08:23
If you follow the pattern from plugin_globals.cc,
dmichael (off chromium)
2011/08/24 21:21:30
Oops. I had the change in a git repo that was set
|
+ return; |
if (print_settings_bytes != sizeof(struct PP_PrintSettings_Dev)) |
return; |
struct PP_PrintSettings_Dev* pp_print_settings = |
reinterpret_cast<struct PP_PrintSettings_Dev*>(print_settings); |
- *pages_required = PPPPrintingInterface()->Begin(instance, pp_print_settings); |
+ *pages_required = ppp_printing->Begin(instance, pp_print_settings); |
DebugPrintf("PPP_Printing::Begin: pages_required=%"NACL_PRId32"\n", |
*pages_required); |
@@ -96,13 +93,16 @@ void PppPrintingRpcServer::PPP_Printing_PrintPages( |
rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
NaClSrpcClosureRunner runner(done); |
+ const PPP_Printing_Dev* ppp_printing = PPPPrinting(); |
+ if (ppp_printing == NULL || ppp_printing->PrintPages == NULL) |
+ return; |
elijahtaylor (use chromium)
2011/08/24 20:08:23
same
|
if (page_ranges_bytes < kPPPrintPageNumberRangeBytes * page_range_count) |
return; |
struct PP_PrintPageNumberRange_Dev* pp_page_ranges = |
reinterpret_cast<struct PP_PrintPageNumberRange_Dev*>(page_ranges); |
- *image_data = PPPPrintingInterface()->PrintPages(instance, |
- pp_page_ranges, |
- page_range_count); |
+ *image_data = ppp_printing->PrintPages(instance, |
+ pp_page_ranges, |
+ page_range_count); |
DebugPrintf("PPP_Printing::PrintPages: image_data=%"NACL_PRIu32"\n", |
*image_data); |
@@ -117,8 +117,12 @@ void PppPrintingRpcServer::PPP_Printing_End( |
rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
NaClSrpcClosureRunner runner(done); |
- PPPPrintingInterface()->End(instance); |
+ const PPP_Printing_Dev* ppp_printing = PPPPrinting(); |
+ if (ppp_printing == NULL || ppp_printing->End == NULL) |
+ return; |
elijahtaylor (use chromium)
2011/08/24 20:08:23
same
|
+ ppp_printing->End(instance); |
DebugPrintf("PPP_Printing::End\n"); |
rpc->result = NACL_SRPC_RESULT_OK; |
} |
+ |