Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1061)

Side by Side Diff: src/shared/ppapi_proxy/browser_ppp_printing.cc

Issue 7714041: Update proxy for PPP_Printing_Dev to deal with new QuerySupportedFormats (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h" 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_printing.h"
6 6
7 // Include file order cannot be observed because ppp_instance declares a
8 // structure return type that causes an error on Windows.
9 // TODO(sehr, brettw): fix the return types and include order in PPAPI.
10 #include "native_client/src/third_party/ppapi/c/pp_instance.h"
11 #include "native_client/src/third_party/ppapi/c/pp_resource.h"
12 #include "srpcgen/ppp_rpc.h"
13 #include "native_client/src/include/portability.h" 7 #include "native_client/src/include/portability.h"
14 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h"
15 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" 9 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h"
10 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h"
elijahtaylor (use chromium) 2011/08/24 20:08:23 Is this include kosher? I see in other files: #i
dmichael (off chromium) 2011/08/24 21:21:30 I would contend that all the other code is wrong :
elijahtaylor (use chromium) 2011/08/24 21:55:28 How very enlightened :P Can you check with Polina
16 #include "native_client/src/shared/ppapi_proxy/utility.h" 11 #include "native_client/src/shared/ppapi_proxy/utility.h"
12 #include "native_client/src/third_party/ppapi/c/pp_instance.h"
13 #include "native_client/src/third_party/ppapi/c/pp_resource.h"
17 14
18 namespace ppapi_proxy { 15 namespace ppapi_proxy {
19 16
20 namespace { 17 namespace {
21 18
22 const nacl_abi_size_t kPPPrintOutputFormatBytes =
23 static_cast<nacl_abi_size_t>(sizeof(PP_PrintOutputFormat_Dev));
24 const nacl_abi_size_t kPPPrintSettingsBytes = 19 const nacl_abi_size_t kPPPrintSettingsBytes =
25 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev)); 20 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintSettings_Dev));
26 const nacl_abi_size_t kPPPrintPageNumberRangeBytes = 21 const nacl_abi_size_t kPPPrintPageNumberRangeBytes =
27 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev)); 22 static_cast<nacl_abi_size_t>(sizeof(struct PP_PrintPageNumberRange_Dev));
28 23
29 PP_PrintOutputFormat_Dev* QuerySupportedFormats(PP_Instance instance, 24 uint32_t QuerySupportedFormats(PP_Instance instance) {
30 uint32_t* format_count) {
31 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: " 25 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: "
32 "instance=%"NACL_PRIu32"\n", instance); 26 "instance=%"NACL_PRIu32"\n", instance);
33 27
34 const PPB_Memory_Dev* ppb_memory = PPBMemoryInterface(); 28 uint32_t formats = 0;
35 const nacl_abi_size_t kMaxFormats = 8;
36 nacl_abi_size_t formats_bytes = kMaxFormats * kPPPrintOutputFormatBytes;
37 char* formats =
38 reinterpret_cast<char*>(ppb_memory->MemAlloc(formats_bytes));
39 NaClSrpcError srpc_result = 29 NaClSrpcError srpc_result =
40 PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats( 30 PppPrintingRpcClient::PPP_Printing_QuerySupportedFormats(
41 GetMainSrpcChannel(instance), 31 GetMainSrpcChannel(instance),
42 instance, 32 instance,
43 &formats_bytes, formats, 33 reinterpret_cast<int32_t*>(formats));
44 reinterpret_cast<int32_t*>(format_count));
45 34
46 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n", 35 DebugPrintf("PPP_Printing_Dev::QuerySupportedFormats: %s\n",
47 NaClSrpcErrorString(srpc_result)); 36 NaClSrpcErrorString(srpc_result));
48 37
49 if (*format_count > 0) 38 return formats;
50 return reinterpret_cast<PP_PrintOutputFormat_Dev*>(formats);
51
52 ppb_memory->MemFree(formats);
53 return NULL;
54 } 39 }
55 40
56 int32_t Begin(PP_Instance instance, 41 int32_t Begin(PP_Instance instance,
57 const struct PP_PrintSettings_Dev* print_settings) { 42 const struct PP_PrintSettings_Dev* print_settings) {
58 DebugPrintf("PPP_Printing_Dev::Begin: instance=%"NACL_PRIu32"\n", instance); 43 DebugPrintf("PPP_Printing_Dev::Begin: instance=%"NACL_PRIu32"\n", instance);
59 44
60 int32_t pages_required = 0; 45 int32_t pages_required = 0;
61 NaClSrpcError srpc_result = 46 NaClSrpcError srpc_result =
62 PppPrintingRpcClient::PPP_Printing_Begin( 47 PppPrintingRpcClient::PPP_Printing_Begin(
63 GetMainSrpcChannel(instance), 48 GetMainSrpcChannel(instance),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 QuerySupportedFormats, 96 QuerySupportedFormats,
112 Begin, 97 Begin,
113 PrintPages, 98 PrintPages,
114 End 99 End
115 }; 100 };
116 return &printing_interface; 101 return &printing_interface;
117 } 102 }
118 103
119 } // namespace ppapi_proxy 104 } // namespace ppapi_proxy
120 105
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698