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

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

Issue 12600019: Add Pepper TrueType font API plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check that desc.family value from plugin is UTF-8 before passing on to OS. Created 7 years, 9 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/truetype_font_resource.h"
6
7 #include "base/bind.h"
8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/array_writer.h"
12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/thunk/enter.h"
16
17 using ppapi::thunk::EnterResourceNoLock;
18 using ppapi::thunk::PPB_TrueTypeFont_API;
19
20 namespace {
21
22 } // namespace
23
24 namespace ppapi {
25 namespace proxy {
26
27 TrueTypeFontResource::TrueTypeFontResource(
28 Connection connection,
29 PP_Instance instance,
30 const PP_TrueTypeFontDesc_Dev& desc)
31 : PluginResource(connection, instance) {
32 SerializedTrueTypeFontDesc serialized_desc;
33 serialized_desc.SetFromPPTrueTypeFontDesc(desc);
34 SendCreate(RENDERER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc));
35 }
36
37 TrueTypeFontResource::~TrueTypeFontResource() {
38 }
39
40 PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() {
41 return this;
42 }
43
44 int32_t TrueTypeFontResource::Describe(
45 PP_TrueTypeFontDesc_Dev* desc,
46 scoped_refptr<TrackedCallback> callback) {
47
48 Call<PpapiPluginMsg_TrueTypeFont_DescribeReply>(RENDERER,
49 PpapiHostMsg_TrueTypeFont_Describe(),
50 base::Bind(&TrueTypeFontResource::OnPluginMsgDescribeComplete, this,
51 callback, desc));
52 return PP_OK_COMPLETIONPENDING;
53 }
54
55 int32_t TrueTypeFontResource::GetTableTags(
56 const PP_ArrayOutput& output,
57 scoped_refptr<TrackedCallback> callback) {
58 Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(RENDERER,
59 PpapiHostMsg_TrueTypeFont_GetTableTags(),
60 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete, this,
61 callback, output));
62 return PP_OK_COMPLETIONPENDING;
63 }
64
65 int32_t TrueTypeFontResource::GetTable(
66 uint32_t table,
67 int32_t offset,
68 int32_t max_data_length,
69 const PP_ArrayOutput& output,
70 scoped_refptr<TrackedCallback> callback) {
71 Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>(RENDERER,
72 PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length),
73 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete, this,
74 callback, output));
75 return PP_OK_COMPLETIONPENDING;
76 }
77
78 void TrueTypeFontResource::OnPluginMsgDescribeComplete(
79 scoped_refptr<TrackedCallback> callback,
80 PP_TrueTypeFontDesc_Dev* pp_desc,
81 const ResourceMessageReplyParams& params,
82 const ppapi::proxy::SerializedTrueTypeFontDesc& desc) {
83 int32_t result = params.result();
84 if (result == PP_OK)
85 desc.CopyToPPTrueTypeFontDesc(pp_desc);
86 callback->Run(result);
87 }
88
89 void TrueTypeFontResource::OnPluginMsgGetTableTagsComplete(
90 scoped_refptr<TrackedCallback> callback,
91 PP_ArrayOutput array_output,
92 const ResourceMessageReplyParams& params,
93 const std::vector<uint32_t>& tag_array) {
94 // The result code should contain the data size if it's positive.
95 int32_t result = params.result();
96 DCHECK((result < 0 && tag_array.size() == 0) ||
97 result == static_cast<int32_t>(tag_array.size()));
jschuh 2013/03/14 21:56:07 If result is negative, wouldn't you end up passing
bbudge 2013/03/14 23:20:23 Result is negative when there is a Pepper error. B
jschuh 2013/03/15 18:28:01 Gah, sorry. My sleep addled brain translated it to
98
99 ArrayWriter output;
100 output.set_pp_array_output(array_output);
101 if (output.is_valid())
102 output.StoreArray(&tag_array[0], std::max(0, result));
103 else
104 result = PP_ERROR_FAILED;
105
106 callback->Run(result);
107 }
108
109 void TrueTypeFontResource::OnPluginMsgGetTableComplete(
110 scoped_refptr<TrackedCallback> callback,
111 PP_ArrayOutput array_output,
112 const ResourceMessageReplyParams& params,
113 const std::string& data) {
114 // The result code should contain the data size if it's positive.
115 int32_t result = params.result();
116 DCHECK((result < 0 && data.size() == 0) ||
117 result == static_cast<int32_t>(data.size()));
jschuh 2013/03/14 21:56:07 Same question as above.
bbudge 2013/03/14 23:20:23 Same reply too. On 2013/03/14 21:56:07, Justin Sch
118
119 ArrayWriter output;
120 output.set_pp_array_output(array_output);
121 if (output.is_valid())
122 output.StoreArray(data.data(), std::max(0, result));
123 else
124 result = PP_ERROR_FAILED;
125
126 callback->Run(result);
127 }
128
129 } // namespace proxy
130 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698