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

Side by Side Diff: ppapi/proxy/ppb_pdf_proxy.cc

Issue 7874002: This patch tries to remove most of the manual registration for Pepper interfaces, and replaces it... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
« no previous file with comments | « ppapi/proxy/ppb_pdf_proxy.h ('k') | ppapi/proxy/ppb_surface_3d_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium 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 "ppapi/proxy/ppb_pdf_proxy.h" 5 #include "ppapi/proxy/ppb_pdf_proxy.h"
6 6
7 #include <string.h> // For memcpy. 7 #include <string.h> // For memcpy.
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return true; 111 return true;
112 } 112 }
113 113
114 const PPB_PDF pdf_interface = { 114 const PPB_PDF pdf_interface = {
115 NULL, // &GetLocalizedString, 115 NULL, // &GetLocalizedString,
116 NULL, // &GetResourceImage, 116 NULL, // &GetResourceImage,
117 &GetFontFileWithFallback, 117 &GetFontFileWithFallback,
118 &GetFontTableForPrivateFontFile, 118 &GetFontTableForPrivateFontFile,
119 }; 119 };
120 120
121 InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher, 121 InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher) {
122 const void* target_interface) { 122 return new PPB_PDF_Proxy(dispatcher);
123 return new PPB_PDF_Proxy(dispatcher, target_interface);
124 } 123 }
125 124
126 } // namespace 125 } // namespace
127 126
128 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher, 127 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher)
129 const void* target_interface) 128 : InterfaceProxy(dispatcher),
130 : InterfaceProxy(dispatcher, target_interface) { 129 ppb_pdf_impl_(NULL) {
130 if (!dispatcher->IsPlugin()) {
131 ppb_pdf_impl_ = static_cast<const PPB_PDF*>(
132 dispatcher->local_get_interface()(PPB_PDF_INTERFACE));
133 }
131 } 134 }
132 135
133 PPB_PDF_Proxy::~PPB_PDF_Proxy() { 136 PPB_PDF_Proxy::~PPB_PDF_Proxy() {
134 } 137 }
135 138
136 // static 139 // static
137 const InterfaceProxy::Info* PPB_PDF_Proxy::GetInfo() { 140 const InterfaceProxy::Info* PPB_PDF_Proxy::GetInfo() {
138 static const Info info = { 141 static const Info info = {
139 &pdf_interface, 142 &pdf_interface,
140 PPB_PDF_INTERFACE, 143 PPB_PDF_INTERFACE,
(...skipping 18 matching lines...) Expand all
159 } 162 }
160 163
161 void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( 164 void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback(
162 PP_Instance instance, 165 PP_Instance instance,
163 const SerializedFontDescription& in_desc, 166 const SerializedFontDescription& in_desc,
164 int32_t charset, 167 int32_t charset,
165 HostResource* result) { 168 HostResource* result) {
166 PP_FontDescription_Dev desc; 169 PP_FontDescription_Dev desc;
167 in_desc.SetToPPFontDescription(dispatcher(), &desc, false); 170 in_desc.SetToPPFontDescription(dispatcher(), &desc, false);
168 result->SetHostResource(instance, 171 result->SetHostResource(instance,
169 ppb_pdf_target()->GetFontFileWithFallback( 172 ppb_pdf_impl_->GetFontFileWithFallback(
170 instance, &desc, static_cast<PP_PrivateFontCharset>(charset))); 173 instance, &desc, static_cast<PP_PrivateFontCharset>(charset)));
171 } 174 }
172 175
173 void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile( 176 void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile(
174 const HostResource& font_file, 177 const HostResource& font_file,
175 uint32_t table, 178 uint32_t table,
176 std::string* result) { 179 std::string* result) {
177 // TODO(brettw): It would be nice not to copy here. At least on Linux, 180 // TODO(brettw): It would be nice not to copy here. At least on Linux,
178 // we can map the font file into shared memory and read it that way. 181 // we can map the font file into shared memory and read it that way.
179 uint32_t table_length = 0; 182 uint32_t table_length = 0;
180 if (!ppb_pdf_target()->GetFontTableForPrivateFontFile( 183 if (!ppb_pdf_impl_->GetFontTableForPrivateFontFile(
181 font_file.host_resource(), table, NULL, &table_length)) 184 font_file.host_resource(), table, NULL, &table_length))
182 return; 185 return;
183 186
184 result->resize(table_length); 187 result->resize(table_length);
185 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), 188 ppb_pdf_impl_->GetFontTableForPrivateFontFile(font_file.host_resource(),
186 table, const_cast<char*>(result->c_str()), &table_length); 189 table, const_cast<char*>(result->c_str()), &table_length);
187 } 190 }
188 191
189 } // namespace proxy 192 } // namespace proxy
190 } // namespace ppapi 193 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_pdf_proxy.h ('k') | ppapi/proxy/ppb_surface_3d_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698