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

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

Issue 337203003: Move PPB_TrueTypeFont_Dev host from renderer to browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Check fd / HANDLE / FontRef for validity. Created 6 years, 6 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/truetype_font_resource.h ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 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 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/truetype_font_resource.h" 5 #include "ppapi/proxy/truetype_font_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ipc/ipc_message.h" 8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/array_writer.h" 11 #include "ppapi/shared_impl/array_writer.h"
12 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/resource_tracker.h" 13 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/shared_impl/var.h" 14 #include "ppapi/shared_impl/var.h"
15 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
16 16
17 using ppapi::thunk::EnterResourceNoLock; 17 using ppapi::thunk::EnterResourceNoLock;
18 using ppapi::thunk::PPB_TrueTypeFont_API; 18 using ppapi::thunk::PPB_TrueTypeFont_API;
19 19
20 namespace { 20 namespace {
21 21
22 } // namespace 22 } // namespace
23 23
24 namespace ppapi { 24 namespace ppapi {
25 namespace proxy { 25 namespace proxy {
26 26
27 TrueTypeFontResource::TrueTypeFontResource( 27 TrueTypeFontResource::TrueTypeFontResource(Connection connection,
28 Connection connection, 28 PP_Instance instance,
29 PP_Instance instance, 29 const PP_TrueTypeFontDesc_Dev& desc)
30 const PP_TrueTypeFontDesc_Dev& desc) 30 : PluginResource(connection, instance),
31 : PluginResource(connection, instance) { 31 create_result_(PP_OK_COMPLETIONPENDING),
32 describe_desc_(NULL) {
32 SerializedTrueTypeFontDesc serialized_desc; 33 SerializedTrueTypeFontDesc serialized_desc;
33 serialized_desc.SetFromPPTrueTypeFontDesc(desc); 34 serialized_desc.SetFromPPTrueTypeFontDesc(desc);
34 SendCreate(RENDERER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc)); 35 SendCreate(BROWSER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc));
35 } 36 }
36 37
37 TrueTypeFontResource::~TrueTypeFontResource() { 38 TrueTypeFontResource::~TrueTypeFontResource() {
38 } 39 }
39 40
40 PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() { 41 PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() {
41 return this; 42 return this;
42 } 43 }
43 44
44 int32_t TrueTypeFontResource::Describe( 45 int32_t TrueTypeFontResource::Describe(
45 PP_TrueTypeFontDesc_Dev* desc, 46 PP_TrueTypeFontDesc_Dev* desc,
46 scoped_refptr<TrackedCallback> callback) { 47 scoped_refptr<TrackedCallback> callback) {
47 Call<PpapiPluginMsg_TrueTypeFont_DescribeReply>(RENDERER, 48 if (describe_callback_)
48 PpapiHostMsg_TrueTypeFont_Describe(), 49 return PP_ERROR_INPROGRESS;
49 base::Bind(&TrueTypeFontResource::OnPluginMsgDescribeComplete, this, 50
50 callback, desc)); 51 if (create_result_ == PP_OK) {
51 return PP_OK_COMPLETIONPENDING; 52 desc_.CopyToPPTrueTypeFontDesc(desc);
53 } else if (create_result_ == PP_OK_COMPLETIONPENDING) {
54 describe_desc_ = desc;
55 describe_callback_ = callback;
56 }
57
58 return create_result_;
52 } 59 }
53 60
54 int32_t TrueTypeFontResource::GetTableTags( 61 int32_t TrueTypeFontResource::GetTableTags(
55 const PP_ArrayOutput& output, 62 const PP_ArrayOutput& output,
56 scoped_refptr<TrackedCallback> callback) { 63 scoped_refptr<TrackedCallback> callback) {
57 Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(RENDERER, 64 Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(
65 BROWSER,
58 PpapiHostMsg_TrueTypeFont_GetTableTags(), 66 PpapiHostMsg_TrueTypeFont_GetTableTags(),
59 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete, this, 67 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete,
60 callback, output)); 68 this,
69 callback,
70 output));
71
61 return PP_OK_COMPLETIONPENDING; 72 return PP_OK_COMPLETIONPENDING;
62 } 73 }
63 74
64 int32_t TrueTypeFontResource::GetTable( 75 int32_t TrueTypeFontResource::GetTable(
65 uint32_t table, 76 uint32_t table,
66 int32_t offset, 77 int32_t offset,
67 int32_t max_data_length, 78 int32_t max_data_length,
68 const PP_ArrayOutput& output, 79 const PP_ArrayOutput& output,
69 scoped_refptr<TrackedCallback> callback) { 80 scoped_refptr<TrackedCallback> callback) {
70 Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>(RENDERER, 81 Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>(
82 BROWSER,
71 PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length), 83 PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length),
72 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete, this, 84 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete,
73 callback, output)); 85 this,
86 callback,
87 output));
88
74 return PP_OK_COMPLETIONPENDING; 89 return PP_OK_COMPLETIONPENDING;
75 } 90 }
76 91
77 void TrueTypeFontResource::OnPluginMsgDescribeComplete( 92 void TrueTypeFontResource::OnReplyReceived(
78 scoped_refptr<TrackedCallback> callback,
79 PP_TrueTypeFontDesc_Dev* pp_desc,
80 const ResourceMessageReplyParams& params, 93 const ResourceMessageReplyParams& params,
81 const ppapi::proxy::SerializedTrueTypeFontDesc& desc) { 94 const IPC::Message& msg) {
82 int32_t result = params.result(); 95 PPAPI_BEGIN_MESSAGE_MAP(TrueTypeFontResource, msg)
83 if (result == PP_OK) 96 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(PpapiPluginMsg_TrueTypeFont_CreateReply,
84 desc.CopyToPPTrueTypeFontDesc(pp_desc); 97 OnPluginMsgCreateComplete)
98 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
99 PluginResource::OnReplyReceived(params, msg))
100 PPAPI_END_MESSAGE_MAP()
101 }
85 102
86 callback->Run(result); 103 void TrueTypeFontResource::OnPluginMsgCreateComplete(
104 const ResourceMessageReplyParams& params,
105 const ppapi::proxy::SerializedTrueTypeFontDesc& desc,
106 int32_t result) {
107 DCHECK(result != PP_OK_COMPLETIONPENDING);
108 DCHECK(create_result_ == PP_OK_COMPLETIONPENDING);
109 create_result_ = result;
110 if (create_result_ == PP_OK)
111 desc_ = desc;
112
113 // Now complete any pending Describe operation.
114 if (TrackedCallback::IsPending(describe_callback_)) {
115 desc_.CopyToPPTrueTypeFontDesc(describe_desc_);
116 describe_desc_ = NULL;
117 scoped_refptr<TrackedCallback> callback;
118 callback.swap(describe_callback_);
119 callback->Run(create_result_ == PP_OK ? PP_OK : PP_ERROR_FAILED);
120 }
87 } 121 }
88 122
89 void TrueTypeFontResource::OnPluginMsgGetTableTagsComplete( 123 void TrueTypeFontResource::OnPluginMsgGetTableTagsComplete(
90 scoped_refptr<TrackedCallback> callback, 124 scoped_refptr<TrackedCallback> callback,
91 PP_ArrayOutput array_output, 125 PP_ArrayOutput array_output,
92 const ResourceMessageReplyParams& params, 126 const ResourceMessageReplyParams& params,
93 const std::vector<uint32_t>& tag_array) { 127 const std::vector<uint32_t>& tag_array) {
94 // The result code should contain the data size if it's positive. 128 // The result code should contain the data size if it's positive.
95 int32_t result = params.result(); 129 int32_t result = params.result();
96 DCHECK((result < 0 && tag_array.size() == 0) || 130 DCHECK((result < 0 && tag_array.size() == 0) ||
(...skipping 24 matching lines...) Expand all
121 if (output.is_valid()) 155 if (output.is_valid())
122 output.StoreArray(data.data(), std::max(0, result)); 156 output.StoreArray(data.data(), std::max(0, result));
123 else 157 else
124 result = PP_ERROR_FAILED; 158 result = PP_ERROR_FAILED;
125 159
126 callback->Run(result); 160 callback->Run(result);
127 } 161 }
128 162
129 } // namespace proxy 163 } // namespace proxy
130 } // namespace ppapi 164 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/truetype_font_resource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698