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

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

Issue 7623018: Move host resource from the proxy to the shared_impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed 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
« 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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "ppapi/c/private/ppb_pdf.h" 14 #include "ppapi/c/private/ppb_pdf.h"
15 #include "ppapi/proxy/plugin_dispatcher.h" 15 #include "ppapi/proxy/plugin_dispatcher.h"
16 #include "ppapi/proxy/plugin_resource.h" 16 #include "ppapi/proxy/plugin_resource.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/thunk/enter.h"
20 #include "ppapi/thunk/ppb_pdf_api.h"
21
22 using ppapi::HostResource;
23 using ppapi::thunk::PPB_PDFFont_API;
24 using ppapi::thunk::EnterResource;
19 25
20 namespace pp { 26 namespace pp {
21 namespace proxy { 27 namespace proxy {
22 28
23 class PrivateFontFile : public PluginResource { 29 class PrivateFontFile : public PluginResource,
30 public PPB_PDFFont_API {
24 public: 31 public:
25 PrivateFontFile(const HostResource& resource) : PluginResource(resource) { 32 PrivateFontFile(const HostResource& resource) : PluginResource(resource) {
26 } 33 }
27 virtual ~PrivateFontFile() {} 34 virtual ~PrivateFontFile() {}
28 35
29 // Resource overrides. 36 PPB_PDFFont_API* AsPPB_PDFFont_API() { return this; }
30 virtual PrivateFontFile* AsPrivateFontFile() { return this; }
31 37
32 // Sees if we have a cache of the font table and returns a pointer to it. 38 // Sees if we have a cache of the font table and returns a pointer to it.
33 // Returns NULL if we don't have it. 39 // Returns NULL if we don't have it.
34 std::string* GetFontTable(uint32_t table) const; 40 std::string* GetFontTable(uint32_t table) const;
35 41
36 std::string* AddFontTable(uint32_t table, const std::string& contents); 42 std::string* AddFontTable(uint32_t table, const std::string& contents);
37 43
38 private: 44 private:
39 typedef std::map<uint32_t, linked_ptr<std::string> > FontTableMap; 45 typedef std::map<uint32_t, linked_ptr<std::string> > FontTableMap;
40 FontTableMap font_tables_; 46 FontTableMap font_tables_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return 0; 82 return 0;
77 83
78 return PluginResourceTracker::GetInstance()->AddResource( 84 return PluginResourceTracker::GetInstance()->AddResource(
79 new PrivateFontFile(result)); 85 new PrivateFontFile(result));
80 } 86 }
81 87
82 bool GetFontTableForPrivateFontFile(PP_Resource font_file, 88 bool GetFontTableForPrivateFontFile(PP_Resource font_file,
83 uint32_t table, 89 uint32_t table,
84 void* output, 90 void* output,
85 uint32_t* output_length) { 91 uint32_t* output_length) {
86 PrivateFontFile* object = PluginResource::GetAs<PrivateFontFile>(font_file); 92 EnterResource<PPB_PDFFont_API> enter(font_file, true);
87 if (!object) 93 if (enter.failed())
88 return false; 94 return false;
95
96 PrivateFontFile* object = static_cast<PrivateFontFile*>(enter.object());
89 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( 97 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(
90 object->instance()); 98 object->instance());
91 if (!dispatcher) 99 if (!dispatcher)
92 return false; 100 return false;
93 101
94 std::string* contents = object->GetFontTable(table); 102 std::string* contents = object->GetFontTable(table);
95 if (!contents) { 103 if (!contents) {
96 std::string deserialized; 104 std::string deserialized;
97 dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile( 105 dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile(
98 INTERFACE_ID_PPB_PDF, object->host_resource(), table, &deserialized)); 106 INTERFACE_ID_PPB_PDF, object->host_resource(), table, &deserialized));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 font_file.host_resource(), table, NULL, &table_length)) 185 font_file.host_resource(), table, NULL, &table_length))
178 return; 186 return;
179 187
180 result->resize(table_length); 188 result->resize(table_length);
181 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), 189 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(),
182 table, const_cast<char*>(result->c_str()), &table_length); 190 table, const_cast<char*>(result->c_str()), &table_length);
183 } 191 }
184 192
185 } // namespace proxy 193 } // namespace proxy
186 } // namespace pp 194 } // namespace pp
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