diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:40:39 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:40:39 +0000 |
commit | f24448db9f893c5dde10ed1ae4cead436e18f64f (patch) | |
tree | c224a27ed5949a761ed2f62b75cedae0fa2014e2 /ppapi/proxy/ppb_pdf_proxy.cc | |
parent | e9319bf33e2b7e6bdd2fa005b212f2fcf0896883 (diff) | |
download | chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.zip chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.tar.gz chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.tar.bz2 |
Refactor PPAPI proxy resource handling to maintain which host they came from,
and to map back to that host when calling functions on them. Adds a mapping
between resources generated by the hosts to a new list inside the plugin so
there can't be overlaps.
This means there are now two meanings for a PP_Resource, one in the plugin
process and one in the host process. This is potentially very confusing. I
introduced a new object called a HostResource that always represents a
"host" PP_Resource to try to prevent errors. In the plugin side of the proxy,
it only deals with PP_Resources valid in the plugin, and SerializedResources
valid in the host. It also encapsulates the associated instance, which
simplifies some code.
Each PluginResource object maintains its SerializedResource which the proxy
uses to send to the host for requests. This requires getting the PluginResource
object in more proxy calls.
This fixes a bug in var sending introduced in my previous patch. The var
releasing from EndSendPassRef used the host var rather than the plugin var. I
had to add more plumbing to get the dispatcher at this location and convert
to a plugin var.
I removed the separate file for ImageData and put it in ppb_image_data_proxy
like for the other resource types.
TEST=some unit tests included
BUG=none
Review URL: http://codereview.chromium.org/6334016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_pdf_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppb_pdf_proxy.cc | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/ppapi/proxy/ppb_pdf_proxy.cc b/ppapi/proxy/ppb_pdf_proxy.cc index 7ad8326..e3c656f 100644 --- a/ppapi/proxy/ppb_pdf_proxy.cc +++ b/ppapi/proxy/ppb_pdf_proxy.cc @@ -22,7 +22,8 @@ namespace proxy { class PrivateFontFile : public PluginResource { public: - PrivateFontFile(PP_Instance instance) : PluginResource(instance) {} + PrivateFontFile(const HostResource& resource) : PluginResource(resource) { + } virtual ~PrivateFontFile() {} // Resource overrides. @@ -68,15 +69,14 @@ PP_Resource GetFontFileWithFallback( SerializedFontDescription desc; desc.SetFromPPFontDescription(dispatcher, *description, true); - PP_Resource result = 0; + HostResource result; dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontFileWithFallback( INTERFACE_ID_PPB_PDF, instance, desc, charset, &result)); - if (!result) + if (result.is_null()) return 0; - linked_ptr<PrivateFontFile> object(new PrivateFontFile(instance)); - PluginResourceTracker::GetInstance()->AddResource(result, object); - return result; + linked_ptr<PrivateFontFile> object(new PrivateFontFile(result)); + return PluginResourceTracker::GetInstance()->AddResource(object); } bool GetFontTableForPrivateFontFile(PP_Resource font_file, @@ -95,7 +95,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file, if (!contents) { std::string deserialized; dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile( - INTERFACE_ID_PPB_PDF, font_file, table, &deserialized)); + INTERFACE_ID_PPB_PDF, object->host_resource(), table, &deserialized)); if (deserialized.empty()) return false; contents = object->AddFontTable(table, deserialized); @@ -149,26 +149,28 @@ void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( PP_Instance instance, const SerializedFontDescription& in_desc, int32_t charset, - PP_Resource* result) { + HostResource* result) { PP_FontDescription_Dev desc; in_desc.SetToPPFontDescription(dispatcher(), &desc, false); - *result = ppb_pdf_target()->GetFontFileWithFallback(instance, &desc, - static_cast<PP_PrivateFontCharset>(charset)); + result->SetHostResource(instance, + ppb_pdf_target()->GetFontFileWithFallback( + instance, &desc, static_cast<PP_PrivateFontCharset>(charset))); } -void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile(PP_Resource font_file, - uint32_t table, - std::string* result) { +void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile( + const HostResource& font_file, + uint32_t table, + std::string* result) { // TODO(brettw): It would be nice not to copy here. At least on Linux, // we can map the font file into shared memory and read it that way. uint32_t table_length = 0; if (!ppb_pdf_target()->GetFontTableForPrivateFontFile( - font_file, table, NULL, &table_length)) + font_file.host_resource(), table, NULL, &table_length)) return; result->resize(table_length); - ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file, table, - const_cast<char*>(result->c_str()), &table_length); + ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), + table, const_cast<char*>(result->c_str()), &table_length); } } // namespace proxy |