Commit 5931a643 authored by dmichael@chromium.org's avatar dmichael@chromium.org

ppapi: Make 0.4 the default for PPP_Printing_Dev, leave backwards-compat.

Since I didn't land this before the NaCl proxy move to chrome, I had to incorporate the proxy changes that were in http://codereview.chromium.org/7714041/

After PDF lands, I should be able to remove backwards-compat code.

BUG=80696
TEST=ppapi tests, manual test of PDF plugin

Review URL: http://codereview.chromium.org/7718004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98684 0039d316-1c4b-4281-b951-d872f2087c98
parent 6a892ebc
...@@ -36,19 +36,10 @@ typedef enum { ...@@ -36,19 +36,10 @@ typedef enum {
PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4 = 1u << 2 PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4 = 1u << 2
} PP_PrintOutputFormat_Dev_0_4; } PP_PrintOutputFormat_Dev_0_4;
/* TODO(dmichael): Remove the conditional compilation when NaCl proxy is
ported to 0.4. Remove 0.3 when PDF is ported. */
#ifdef PPP_PRINTING_DEV_USE_0_4
typedef PP_PrintOutputFormat_Dev_0_4 PP_PrintOutputFormat_Dev; typedef PP_PrintOutputFormat_Dev_0_4 PP_PrintOutputFormat_Dev;
#define PP_PRINTOUTPUTFORMAT_RASTER PP_PRINTOUTPUTFORMAT_RASTER_0_4 #define PP_PRINTOUTPUTFORMAT_RASTER PP_PRINTOUTPUTFORMAT_RASTER_0_4
#define PP_PRINTOUTPUTFORMAT_PDF PP_PRINTOUTPUTFORMAT_PDF_0_4 #define PP_PRINTOUTPUTFORMAT_PDF PP_PRINTOUTPUTFORMAT_PDF_0_4
#define PP_PRINTOUTPUTFORMAT_POSTSCRIPT PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4 #define PP_PRINTOUTPUTFORMAT_POSTSCRIPT PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_4
#else
typedef PP_PrintOutputFormat_Dev_0_3 PP_PrintOutputFormat_Dev;
#define PP_PRINTOUTPUTFORMAT_RASTER PP_PRINTOUTPUTFORMAT_RASTER_0_3
#define PP_PRINTOUTPUTFORMAT_PDF PP_PRINTOUTPUTFORMAT_PDF_0_3
#define PP_PRINTOUTPUTFORMAT_POSTSCRIPT PP_PRINTOUTPUTFORMAT_POSTSCRIPT_0_3
#endif
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOutputFormat_Dev, 4); PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_PrintOutputFormat_Dev, 4);
struct PP_PrintSettings_Dev { struct PP_PrintSettings_Dev {
...@@ -98,13 +89,8 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintPageNumberRange_Dev, 8); ...@@ -98,13 +89,8 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_PrintPageNumberRange_Dev, 8);
/* Interface for the plugin to implement printing. */ /* Interface for the plugin to implement printing. */
#define PPP_PRINTING_DEV_INTERFACE_0_3 "PPP_Printing(Dev);0.3" #define PPP_PRINTING_DEV_INTERFACE_0_3 "PPP_Printing(Dev);0.3"
#define PPP_PRINTING_DEV_INTERFACE_0_4 "PPP_Printing(Dev);0.4" #define PPP_PRINTING_DEV_INTERFACE_0_4 "PPP_Printing(Dev);0.4"
#ifdef PPP_PRINTING_DEV_USE_0_4
#define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_4 #define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_4
#else
#define PPP_PRINTING_DEV_INTERFACE PPP_PRINTING_DEV_INTERFACE_0_3
#endif
#ifdef PPP_PRINTING_DEV_USE_0_4
struct PPP_Printing_Dev { struct PPP_Printing_Dev {
/** /**
* Returns a bit field representing the supported print output formats. For * Returns a bit field representing the supported print output formats. For
...@@ -138,37 +124,13 @@ struct PPP_Printing_Dev { ...@@ -138,37 +124,13 @@ struct PPP_Printing_Dev {
/** Ends the print session. Further calls to PrintPage will fail. */ /** Ends the print session. Further calls to PrintPage will fail. */
void (*End)(PP_Instance instance); void (*End)(PP_Instance instance);
}; };
#else
struct PPP_Printing_Dev {
/**
* Returns an array of supported print output formats. The array is allocated
* using PPB_Core.MemAlloc. The caller is responsible for freeing the array
* using PPB_Core.MemFree.
* Sets |*format_count| to 0 returns NULL if printing is not supported at
* all.
*/
PP_PrintOutputFormat_Dev* (*QuerySupportedFormats)(
PP_Instance instance, uint32_t* format_count);
/* See the alternate definition of PPP_Printing_Dev above for documentation
* on these functions.
*/
int32_t (*Begin)(PP_Instance instance,
const struct PP_PrintSettings_Dev* print_settings);
PP_Resource (*PrintPages)(
PP_Instance instance,
const struct PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count);
void (*End)(PP_Instance instance);
};
#endif
/* The following versioned structs are exact copies of the above unversioned /* The following versioned structs are exact copies of the above unversioned
structs, except that PP_PrintSettings_Dev_0_3 or PP_PrintSettings_Dev_0_4 is struct, except that PP_PrintSettings_Dev_0_3 or PP_PrintSettings_Dev_0_4 is
used instead of PP_PrintSettings_Dev. This is for use by Chrome & NaCl, which used instead of PP_PrintSettings_Dev. This is for use by Chrome & NaCl, which
always use versioned type names. Each must be bit-for-bit compatible with the always use versioned type names. Each must be bit-for-bit compatible with the
associated version of PPP_Printing_Dev above. associated version of PPP_Printing_Dev above.
TODO(dmichael,noelallen): Fix this by having separate internal vs external TODO(dmichael): Remove versioning from this header. */
headers generated by IDL. */
struct PPP_Printing_Dev_0_4 { struct PPP_Printing_Dev_0_4 {
uint32_t (*QuerySupportedFormats)(PP_Instance instance); uint32_t (*QuerySupportedFormats)(PP_Instance instance);
int32_t (*Begin)(PP_Instance instance, int32_t (*Begin)(PP_Instance instance,
...@@ -181,7 +143,7 @@ struct PPP_Printing_Dev_0_4 { ...@@ -181,7 +143,7 @@ struct PPP_Printing_Dev_0_4 {
}; };
struct PPP_Printing_Dev_0_3 { struct PPP_Printing_Dev_0_3 {
PP_PrintOutputFormat_Dev* (*QuerySupportedFormats)( PP_PrintOutputFormat_Dev_0_3* (*QuerySupportedFormats)(
PP_Instance instance, uint32_t* format_count); PP_Instance instance, uint32_t* format_count);
int32_t (*Begin)(PP_Instance instance, int32_t (*Begin)(PP_Instance instance,
const struct PP_PrintSettings_Dev_0_3* print_settings); const struct PP_PrintSettings_Dev_0_3* print_settings);
......
...@@ -14,7 +14,6 @@ namespace { ...@@ -14,7 +14,6 @@ namespace {
static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE; static const char kPPPPrintingInterface[] = PPP_PRINTING_DEV_INTERFACE;
#ifdef PPP_PRINTING_DEV_USE_0_4
uint32_t QuerySupportedFormats(PP_Instance instance) { uint32_t QuerySupportedFormats(PP_Instance instance) {
void* object = void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface); pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
...@@ -22,17 +21,6 @@ uint32_t QuerySupportedFormats(PP_Instance instance) { ...@@ -22,17 +21,6 @@ uint32_t QuerySupportedFormats(PP_Instance instance) {
return 0; return 0;
return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(); return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats();
} }
#else
PP_PrintOutputFormat_Dev* QuerySupportedFormats(PP_Instance instance,
uint32_t* format_count) {
void* object =
pp::Instance::GetPerInstanceObject(instance, kPPPPrintingInterface);
if (!object)
return NULL;
return static_cast<Printing_Dev*>(object)->QuerySupportedPrintOutputFormats(
format_count);
}
#endif
int32_t Begin(PP_Instance instance, int32_t Begin(PP_Instance instance,
const struct PP_PrintSettings_Dev* print_settings) { const struct PP_PrintSettings_Dev* print_settings) {
......
...@@ -22,12 +22,7 @@ class Printing_Dev { ...@@ -22,12 +22,7 @@ class Printing_Dev {
// PPP_Printing_Dev functions exposed as virtual functions for you to // PPP_Printing_Dev functions exposed as virtual functions for you to
// override. // override.
#ifdef PPP_PRINTING_DEV_USE_0_4
virtual uint32_t QuerySupportedPrintOutputFormats() = 0; virtual uint32_t QuerySupportedPrintOutputFormats() = 0;
#else
virtual PP_PrintOutputFormat_Dev* QuerySupportedPrintOutputFormats(
uint32_t* format_count) = 0;
#endif
virtual int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) = 0; virtual int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) = 0;
virtual Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges, virtual Resource PrintPages(const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count) = 0; uint32_t page_range_count) = 0;
......
...@@ -4,53 +4,38 @@ ...@@ -4,53 +4,38 @@
#include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h"
// Include file order cannot be observed because ppp_instance declares a
// structure return type that causes an error on Windows.
// TODO(sehr, brettw): fix the return types and include order in PPAPI.
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
#include "srpcgen/ppp_rpc.h"
#include "native_client/src/include/portability.h" #include "native_client/src/include/portability.h"
#include "native_client/src/shared/ppapi_proxy/browser_globals.h" #include "native_client/src/shared/ppapi_proxy/browser_globals.h"
#include "native_client/src/shared/ppapi_proxy/browser_ppp.h" #include "native_client/src/shared/ppapi_proxy/browser_ppp.h"
#include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h"
#include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/shared/ppapi_proxy/utility.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
namespace ppapi_proxy { namespace ppapi_proxy {
namespace { namespace {
const nacl_abi_size_t kPPPrintOutputFormatBytes =
static_cast<nacl_abi_size_t>(sizeof(PP_PrintOutputFormat_Dev));
const nacl_abi_size_t kPPPrintSettingsBytes = const nacl_abi_size_t kPPPrintSettingsBytes =
static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev));
const nacl_abi_size_t kPPPrintPageNumberRangeBytes = const nacl_abi_size_t kPPPrintPageNumberRangeBytes =
static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev));
PP_PrintOutputFormat_Dev* QuerySupportedFormats(PP_Instance instance, uint32_t QuerySupportedFormats(PP_Instance instance) {
uint32_t* format_count) {
DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: " DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: "
"instance=%"NACL_PRIu32"\n", instance); "instance=%"NACL_PRIu32"\n", instance);
const PPB_Memory_Dev* ppb_memory = PPBMemoryInterface(); int32_t formats = 0;
const nacl_abi_size_t kMaxFormats = 8;
nacl_abi_size_t formats_bytes = kMaxFormats * kPPPrintOutputFormatBytes;
char* formats =
reinterpret_cast<char*>(ppb_memory->MemAlloc(formats_bytes));
NaClSrpcError srpc_result = NaClSrpcError srpc_result =
PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats( PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats(
GetMainSrpcChannel(instance), GetMainSrpcChannel(instance),
instance, instance,
&formats_bytes, formats, &formats);
reinterpret_cast<int32_t*>(format_count));
DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n", DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n",
NaClSrpcErrorString(srpc_result)); NaClSrpcErrorString(srpc_result));
if (*format_count > 0) return static_cast<uint32_t>(formats);
return reinterpret_cast<PP_PrintOutputFormat_Dev*>(formats);
ppb_memory->MemFree(formats);
return NULL;
} }
int32_t Begin(PP_Instance instance, int32_t Begin(PP_Instance instance,
......
...@@ -10,19 +10,17 @@ ...@@ -10,19 +10,17 @@
#include "native_client/src/include/portability_process.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/browser_globals.h"
#include "native_client/src/shared/ppapi_proxy/plugin_globals.h" #include "native_client/src/shared/ppapi_proxy/plugin_globals.h"
#include "native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppp_rpc.h"
#include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/shared/ppapi_proxy/utility.h"
#include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppp.h" #include "ppapi/c/ppp.h"
#include "srpcgen/ppp_rpc.h"
using ppapi_proxy::DebugPrintf; using ppapi_proxy::DebugPrintf;
using ppapi_proxy::PPPPrintingInterface; using ppapi_proxy::PPPPrintingInterface;
namespace { namespace {
const nacl_abi_size_t kPPPrintOutputFormatBytes =
static_cast<nacl_abi_size_t>(sizeof(PP_PrintOutputFormat_Dev));
const nacl_abi_size_t kPPPrintSettingsBytes = const nacl_abi_size_t kPPPrintSettingsBytes =
static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev));
const nacl_abi_size_t kPPPrintPageNumberRangeBytes = const nacl_abi_size_t kPPPrintPageNumberRangeBytes =
...@@ -36,29 +34,15 @@ void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats( ...@@ -36,29 +34,15 @@ void PppPrintingRpcServer::PPP_Printing_QuerySupportedFormats(
// inputs // inputs
PP_Instance instance, PP_Instance instance,
// outputs // outputs
nacl_abi_size_t* formats_bytes, char* formats, int32_t* formats) {
int32_t* format_count) {
rpc->result = NACL_SRPC_RESULT_APP_ERROR; rpc->result = NACL_SRPC_RESULT_APP_ERROR;
NaClSrpcClosureRunner runner(done); NaClSrpcClosureRunner runner(done);
PP_PrintOutputFormat_Dev* pp_formats = uint32_t pp_formats = PPPPrintingInterface()->QuerySupportedFormats(instance);
PPPPrintingInterface()->QuerySupportedFormats( *formats = static_cast<int32_t>(pp_formats);
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);
}
DebugPrintf("PPP_Printing::QuerySupportedFormats: " DebugPrintf("PPP_Printing::QuerySupportedFormats: "
"format_count=%"NACL_PRId32"\n", *format_count); "formats=%"NACL_PRId32"\n", *formats);
rpc->result = NACL_SRPC_RESULT_OK; rpc->result = NACL_SRPC_RESULT_OK;
} }
......
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
{'name': 'PPP_Printing_QuerySupportedFormats', {'name': 'PPP_Printing_QuerySupportedFormats',
'inputs': [['instance', 'PP_Instance'], 'inputs': [['instance', 'PP_Instance'],
], ],
'outputs': [['formats', 'char[]'], # PP_PrintOutputFormat_Dev array 'outputs': [['formats', 'int32_t'], # uint32_t
['format_count', 'int32_t'], # uint32_t
] ]
}, },
{'name': 'PPP_Printing_Begin', {'name': 'PPP_Printing_Begin',
......
...@@ -283,15 +283,13 @@ NaClSrpcError PppMessagingRpcClient::PPP_Messaging_HandleMessage( ...@@ -283,15 +283,13 @@ NaClSrpcError PppMessagingRpcClient::PPP_Messaging_HandleMessage(
NaClSrpcError PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats( NaClSrpcError PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats(
NaClSrpcChannel* channel, NaClSrpcChannel* channel,
PP_Instance instance, PP_Instance instance,
nacl_abi_size_t* formats_bytes, char* formats, int32_t* formats) {
int32_t* format_count) {
NaClSrpcError retval; NaClSrpcError retval;
retval = NaClSrpcInvokeBySignature( retval = NaClSrpcInvokeBySignature(
channel, channel,
"PPP_Printing_QuerySupportedFormats:i:Ci", "PPP_Printing_QuerySupportedFormats:i:i",
instance, instance,
formats_bytes, formats, formats
format_count
); );
if (retval == NACL_SRPC_RESULT_INTERNAL) if (retval == NACL_SRPC_RESULT_INTERNAL)
ppapi_proxy::CleanUpAfterDeadNexe(instance); ppapi_proxy::CleanUpAfterDeadNexe(instance);
......
...@@ -266,8 +266,7 @@ static void PPP_Printing_QuerySupportedFormatsDispatcher( ...@@ -266,8 +266,7 @@ static void PPP_Printing_QuerySupportedFormatsDispatcher(
rpc, rpc,
done, done,
inputs[0]->u.ival, inputs[0]->u.ival,
&(outputs[0]->u.count), outputs[0]->arrays.carr, &(outputs[0]->u.ival)
&(outputs[1]->u.ival)
); );
} }
...@@ -413,7 +412,7 @@ NaClSrpcHandlerDesc PppRpcs::srpc_methods[] = { ...@@ -413,7 +412,7 @@ NaClSrpcHandlerDesc PppRpcs::srpc_methods[] = {
{ "PPP_Instance_DidChangeFocus:ib:", PPP_Instance_DidChangeFocusDispatcher }, { "PPP_Instance_DidChangeFocus:ib:", PPP_Instance_DidChangeFocusDispatcher },
{ "PPP_Instance_HandleDocumentLoad:ii:i", PPP_Instance_HandleDocumentLoadDispatcher }, { "PPP_Instance_HandleDocumentLoad:ii:i", PPP_Instance_HandleDocumentLoadDispatcher },
{ "PPP_Messaging_HandleMessage:iC:", PPP_Messaging_HandleMessageDispatcher }, { "PPP_Messaging_HandleMessage:iC:", PPP_Messaging_HandleMessageDispatcher },
{ "PPP_Printing_QuerySupportedFormats:i:Ci", PPP_Printing_QuerySupportedFormatsDispatcher }, { "PPP_Printing_QuerySupportedFormats:i:i", PPP_Printing_QuerySupportedFormatsDispatcher },
{ "PPP_Printing_Begin:iC:i", PPP_Printing_BeginDispatcher }, { "PPP_Printing_Begin:iC:i", PPP_Printing_BeginDispatcher },
{ "PPP_Printing_PrintPages:iCi:i", PPP_Printing_PrintPagesDispatcher }, { "PPP_Printing_PrintPages:iCi:i", PPP_Printing_PrintPagesDispatcher },
{ "PPP_Printing_End:i:", PPP_Printing_EndDispatcher }, { "PPP_Printing_End:i:", PPP_Printing_EndDispatcher },
......
...@@ -160,8 +160,7 @@ class PppPrintingRpcClient { ...@@ -160,8 +160,7 @@ class PppPrintingRpcClient {
static NaClSrpcError PPP_Printing_QuerySupportedFormats( static NaClSrpcError PPP_Printing_QuerySupportedFormats(
NaClSrpcChannel* channel, NaClSrpcChannel* channel,
PP_Instance instance, PP_Instance instance,
nacl_abi_size_t* formats_bytes, char* formats, int32_t* formats);
int32_t* format_count);
static NaClSrpcError PPP_Printing_Begin( static NaClSrpcError PPP_Printing_Begin(
NaClSrpcChannel* channel, NaClSrpcChannel* channel,
PP_Instance instance, PP_Instance instance,
......
...@@ -176,8 +176,7 @@ class PppPrintingRpcServer { ...@@ -176,8 +176,7 @@ class PppPrintingRpcServer {
NaClSrpcRpc* rpc, NaClSrpcRpc* rpc,
NaClSrpcClosure* done, NaClSrpcClosure* done,
PP_Instance instance, PP_Instance instance,
nacl_abi_size_t* formats_bytes, char* formats, int32_t* formats);
int32_t* format_count);
static void PPP_Printing_Begin( static void PPP_Printing_Begin(
NaClSrpcRpc* rpc, NaClSrpcRpc* rpc,
NaClSrpcClosure* done, NaClSrpcClosure* done,
......
...@@ -310,14 +310,11 @@ class PrintingAdapter : public pp::Printing_Dev { ...@@ -310,14 +310,11 @@ class PrintingAdapter : public pp::Printing_Dev {
proxy->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); proxy->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE));
} }
PP_PrintOutputFormat_Dev* uint32_t QuerySupportedPrintOutputFormats() {
QuerySupportedPrintOutputFormats(uint32_t* format_count) {
if (ppp_printing_ != NULL) { if (ppp_printing_ != NULL) {
return ppp_printing_->QuerySupportedFormats(plugin_->pp_instance(), return ppp_printing_->QuerySupportedFormats(plugin_->pp_instance());
format_count);
} }
*format_count = 0; return 0;
return NULL;
} }
int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) { int32_t PrintBegin(const PP_PrintSettings_Dev& print_settings) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment