| OLD | NEW |
| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace ppapi { | 24 namespace ppapi { |
| 25 namespace proxy { | 25 namespace proxy { |
| 26 | 26 |
| 27 TrueTypeFontResource::TrueTypeFontResource( | 27 TrueTypeFontResource::TrueTypeFontResource( |
| 28 Connection connection, | 28 Connection connection, |
| 29 PP_Instance instance, | 29 PP_Instance instance, |
| 30 const PP_TrueTypeFontDesc_Dev& desc) | 30 const PP_TrueTypeFontDesc_Dev& desc) |
| 31 : PluginResource(connection, instance) { | 31 : PluginResource(connection, instance) { |
| 32 SerializedTrueTypeFontDesc serialized_desc; | 32 SerializedTrueTypeFontDesc serialized_desc; |
| 33 serialized_desc.SetFromPPTrueTypeFontDesc(desc); | 33 serialized_desc.SetFromPPTrueTypeFontDesc(desc); |
| 34 SendCreate(RENDERER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc)); | 34 SendCreate(BROWSER, PpapiHostMsg_TrueTypeFont_Create(serialized_desc)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 TrueTypeFontResource::~TrueTypeFontResource() { | 37 TrueTypeFontResource::~TrueTypeFontResource() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() { | 40 PPB_TrueTypeFont_API* TrueTypeFontResource::AsPPB_TrueTypeFont_API() { |
| 41 return this; | 41 return this; |
| 42 } | 42 } |
| 43 | 43 |
| 44 int32_t TrueTypeFontResource::Describe( | 44 int32_t TrueTypeFontResource::Describe( |
| 45 PP_TrueTypeFontDesc_Dev* desc, | 45 PP_TrueTypeFontDesc_Dev* desc, |
| 46 scoped_refptr<TrackedCallback> callback) { | 46 scoped_refptr<TrackedCallback> callback) { |
| 47 Call<PpapiPluginMsg_TrueTypeFont_DescribeReply>(RENDERER, | 47 Call<PpapiPluginMsg_TrueTypeFont_DescribeReply>( |
| 48 BROWSER, |
| 48 PpapiHostMsg_TrueTypeFont_Describe(), | 49 PpapiHostMsg_TrueTypeFont_Describe(), |
| 49 base::Bind(&TrueTypeFontResource::OnPluginMsgDescribeComplete, this, | 50 base::Bind(&TrueTypeFontResource::OnPluginMsgDescribeComplete, |
| 50 callback, desc)); | 51 this, |
| 52 callback, |
| 53 desc)); |
| 51 return PP_OK_COMPLETIONPENDING; | 54 return PP_OK_COMPLETIONPENDING; |
| 52 } | 55 } |
| 53 | 56 |
| 54 int32_t TrueTypeFontResource::GetTableTags( | 57 int32_t TrueTypeFontResource::GetTableTags( |
| 55 const PP_ArrayOutput& output, | 58 const PP_ArrayOutput& output, |
| 56 scoped_refptr<TrackedCallback> callback) { | 59 scoped_refptr<TrackedCallback> callback) { |
| 57 Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>(RENDERER, | 60 Call<PpapiPluginMsg_TrueTypeFont_GetTableTagsReply>( |
| 61 BROWSER, |
| 58 PpapiHostMsg_TrueTypeFont_GetTableTags(), | 62 PpapiHostMsg_TrueTypeFont_GetTableTags(), |
| 59 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete, this, | 63 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableTagsComplete, |
| 60 callback, output)); | 64 this, |
| 65 callback, |
| 66 output)); |
| 61 return PP_OK_COMPLETIONPENDING; | 67 return PP_OK_COMPLETIONPENDING; |
| 62 } | 68 } |
| 63 | 69 |
| 64 int32_t TrueTypeFontResource::GetTable( | 70 int32_t TrueTypeFontResource::GetTable( |
| 65 uint32_t table, | 71 uint32_t table, |
| 66 int32_t offset, | 72 int32_t offset, |
| 67 int32_t max_data_length, | 73 int32_t max_data_length, |
| 68 const PP_ArrayOutput& output, | 74 const PP_ArrayOutput& output, |
| 69 scoped_refptr<TrackedCallback> callback) { | 75 scoped_refptr<TrackedCallback> callback) { |
| 70 Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>(RENDERER, | 76 Call<PpapiPluginMsg_TrueTypeFont_GetTableReply>( |
| 77 BROWSER, |
| 71 PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length), | 78 PpapiHostMsg_TrueTypeFont_GetTable(table, offset, max_data_length), |
| 72 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete, this, | 79 base::Bind(&TrueTypeFontResource::OnPluginMsgGetTableComplete, |
| 73 callback, output)); | 80 this, |
| 81 callback, |
| 82 output)); |
| 74 return PP_OK_COMPLETIONPENDING; | 83 return PP_OK_COMPLETIONPENDING; |
| 75 } | 84 } |
| 76 | 85 |
| 77 void TrueTypeFontResource::OnPluginMsgDescribeComplete( | 86 void TrueTypeFontResource::OnPluginMsgDescribeComplete( |
| 78 scoped_refptr<TrackedCallback> callback, | 87 scoped_refptr<TrackedCallback> callback, |
| 79 PP_TrueTypeFontDesc_Dev* pp_desc, | 88 PP_TrueTypeFontDesc_Dev* pp_desc, |
| 80 const ResourceMessageReplyParams& params, | 89 const ResourceMessageReplyParams& params, |
| 81 const ppapi::proxy::SerializedTrueTypeFontDesc& desc) { | 90 const ppapi::proxy::SerializedTrueTypeFontDesc& desc) { |
| 82 int32_t result = params.result(); | 91 int32_t result = params.result(); |
| 83 if (result == PP_OK) | 92 if (result == PP_OK) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 if (output.is_valid()) | 130 if (output.is_valid()) |
| 122 output.StoreArray(data.data(), std::max(0, result)); | 131 output.StoreArray(data.data(), std::max(0, result)); |
| 123 else | 132 else |
| 124 result = PP_ERROR_FAILED; | 133 result = PP_ERROR_FAILED; |
| 125 | 134 |
| 126 callback->Run(result); | 135 callback->Run(result); |
| 127 } | 136 } |
| 128 | 137 |
| 129 } // namespace proxy | 138 } // namespace proxy |
| 130 } // namespace ppapi | 139 } // namespace ppapi |
| OLD | NEW |