| 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 #ifndef PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ | 6 #define PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <queue> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "ppapi/proxy/connection.h" | 11 #include "ppapi/proxy/connection.h" |
| 11 #include "ppapi/proxy/plugin_resource.h" | 12 #include "ppapi/proxy/plugin_resource.h" |
| 12 #include "ppapi/proxy/ppapi_proxy_export.h" | 13 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 14 #include "ppapi/proxy/serialized_structs.h" |
| 13 #include "ppapi/shared_impl/var.h" | 15 #include "ppapi/shared_impl/var.h" |
| 14 #include "ppapi/thunk/ppb_truetype_font_api.h" | 16 #include "ppapi/thunk/ppb_truetype_font_api.h" |
| 15 | 17 |
| 16 namespace ppapi { | 18 namespace ppapi { |
| 17 | 19 |
| 18 class TrackedCallback; | 20 class TrackedCallback; |
| 19 | 21 |
| 20 namespace proxy { | 22 namespace proxy { |
| 21 | 23 |
| 22 struct SerializedTrueTypeFontDesc; | 24 struct SerializedTrueTypeFontDesc; |
| 23 | 25 |
| 24 class PPAPI_PROXY_EXPORT TrueTypeFontResource | 26 class PPAPI_PROXY_EXPORT TrueTypeFontResource |
| 25 : public PluginResource, | 27 : public PluginResource, |
| 26 public thunk::PPB_TrueTypeFont_API { | 28 public thunk::PPB_TrueTypeFont_API { |
| 27 public: | 29 public: |
| 28 TrueTypeFontResource(Connection connection, | 30 TrueTypeFontResource(Connection connection, |
| 29 PP_Instance instance, | 31 PP_Instance instance, |
| 30 const PP_TrueTypeFontDesc_Dev& desc); | 32 const PP_TrueTypeFontDesc_Dev& desc); |
| 31 virtual ~TrueTypeFontResource(); | 33 virtual ~TrueTypeFontResource(); |
| 32 | 34 |
| 33 // Resource overrides. | 35 // Resource implementation. |
| 34 virtual thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() OVERRIDE; | 36 virtual thunk::PPB_TrueTypeFont_API* AsPPB_TrueTypeFont_API() OVERRIDE; |
| 35 | 37 |
| 36 // PPB_TrueTypeFont_API implementation. | 38 // PPB_TrueTypeFont_API implementation. |
| 37 virtual int32_t Describe( | 39 virtual int32_t Describe( |
| 38 PP_TrueTypeFontDesc_Dev* desc, | 40 PP_TrueTypeFontDesc_Dev* desc, |
| 39 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 41 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 40 virtual int32_t GetTableTags( | 42 virtual int32_t GetTableTags( |
| 41 const PP_ArrayOutput& output, | 43 const PP_ArrayOutput& output, |
| 42 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 43 virtual int32_t GetTable( | 45 virtual int32_t GetTable( |
| 44 uint32_t table, | 46 uint32_t table, |
| 45 int32_t offset, | 47 int32_t offset, |
| 46 int32_t max_data_length, | 48 int32_t max_data_length, |
| 47 const PP_ArrayOutput& output, | 49 const PP_ArrayOutput& output, |
| 48 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 50 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 49 | 51 |
| 52 // PluginResource implementation. |
| 53 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 54 const IPC::Message& msg) OVERRIDE; |
| 55 |
| 50 private: | 56 private: |
| 51 void OnPluginMsgDescribeComplete( | 57 // If the call to PepperTrueTypeFont::Create hasn't completed, we queue up |
| 52 scoped_refptr<TrackedCallback> callback, | 58 // messages to replay later. |
| 53 PP_TrueTypeFontDesc_Dev* pp_desc, | 59 struct FontOp { |
| 60 enum Type { DESCRIBE, GET_TABLE_TAGS, GET_TABLE }; |
| 61 |
| 62 FontOp(PP_TrueTypeFontDesc_Dev* desc, |
| 63 scoped_refptr<TrackedCallback> callback); |
| 64 FontOp(const PP_ArrayOutput& output, |
| 65 scoped_refptr<TrackedCallback> callback); |
| 66 FontOp(uint32_t table, |
| 67 int32_t offset, |
| 68 int32_t max_data_length, |
| 69 const PP_ArrayOutput& output, |
| 70 scoped_refptr<TrackedCallback> callback); |
| 71 ~FontOp(); |
| 72 |
| 73 Type type; |
| 74 scoped_refptr<TrackedCallback> callback; |
| 75 |
| 76 PP_TrueTypeFontDesc_Dev* desc; |
| 77 PP_ArrayOutput output; |
| 78 uint32_t table; |
| 79 int32_t offset; |
| 80 int32_t max_data_length; |
| 81 }; |
| 82 |
| 83 void OnPluginMsgCreateComplete( |
| 54 const ResourceMessageReplyParams& params, | 84 const ResourceMessageReplyParams& params, |
| 55 const ppapi::proxy::SerializedTrueTypeFontDesc& desc); | 85 const ppapi::proxy::SerializedTrueTypeFontDesc& desc, |
| 86 int32_t result); |
| 56 void OnPluginMsgGetTableTagsComplete( | 87 void OnPluginMsgGetTableTagsComplete( |
| 57 scoped_refptr<TrackedCallback> callback, | 88 scoped_refptr<TrackedCallback> callback, |
| 58 PP_ArrayOutput array_output, | 89 PP_ArrayOutput array_output, |
| 59 const ResourceMessageReplyParams& params, | 90 const ResourceMessageReplyParams& params, |
| 60 const std::vector<uint32_t>& data); | 91 const std::vector<uint32_t>& data); |
| 61 void OnPluginMsgGetTableComplete( | 92 void OnPluginMsgGetTableComplete( |
| 62 scoped_refptr<TrackedCallback> callback, | 93 scoped_refptr<TrackedCallback> callback, |
| 63 PP_ArrayOutput array_output, | 94 PP_ArrayOutput array_output, |
| 64 const ResourceMessageReplyParams& params, | 95 const ResourceMessageReplyParams& params, |
| 65 const std::string& data); | 96 const std::string& data); |
| 66 | 97 |
| 98 void RunFontOp(const FontOp& op); |
| 99 |
| 100 int32_t create_result_; |
| 101 // Valid only when create_result_ == PP_OK. |
| 102 ppapi::proxy::SerializedTrueTypeFontDesc desc_; |
| 103 |
| 104 // Queue font operations until creation has completed. |
| 105 std::queue<FontOp> pending_font_ops_; |
| 106 |
| 67 DISALLOW_COPY_AND_ASSIGN(TrueTypeFontResource); | 107 DISALLOW_COPY_AND_ASSIGN(TrueTypeFontResource); |
| 68 }; | 108 }; |
| 69 | 109 |
| 70 } // namespace proxy | 110 } // namespace proxy |
| 71 } // namespace ppapi | 111 } // namespace ppapi |
| 72 | 112 |
| 73 #endif // PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ | 113 #endif // PPAPI_PROXY_TRUETYPE_FONT_RESOURCE_H_ |
| OLD | NEW |