cc: Include Blink's display list memory usage in rasterize_and_record_micro results.
[chromium-blink-merge.git] / ppapi / proxy / flash_font_file_resource.h
blobfada61d4ffe72e16124623ef7db5f4ec6fc1fb88
1 // Copyright (c) 2012 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.
5 #ifndef PPAPI_PROXY_FLASH_FONT_FILE_RESOURCE_H_
6 #define PPAPI_PROXY_FLASH_FONT_FILE_RESOURCE_H_
8 #include <string>
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "ppapi/c/private/pp_private_font_charset.h"
12 #include "ppapi/proxy/plugin_resource.h"
13 #include "ppapi/proxy/serialized_structs.h"
14 #include "ppapi/thunk/ppb_flash_font_file_api.h"
16 struct PP_BrowserFont_Trusted_Description;
18 namespace ppapi {
19 namespace proxy {
21 // TODO(yzshen): write unittest and browser test.
22 class FlashFontFileResource : public PluginResource,
23 public thunk::PPB_Flash_FontFile_API {
24 public:
25 FlashFontFileResource(Connection connection,
26 PP_Instance instance,
27 const PP_BrowserFont_Trusted_Description* description,
28 PP_PrivateFontCharset charset);
29 ~FlashFontFileResource() override;
31 // Resource overrides.
32 thunk::PPB_Flash_FontFile_API* AsPPB_Flash_FontFile_API() override;
34 // PPB_Flash_FontFile_API.
35 PP_Bool GetFontTable(uint32_t table,
36 void* output,
37 uint32_t* output_length) override;
39 private:
40 // Sees if we have a cache of the font table and returns a pointer to it.
41 // Returns NULL if we don't have it.
42 const std::string* GetFontTable(uint32_t table) const;
44 const std::string* AddFontTable(uint32_t table, const std::string& contents);
46 using FontTableMap =
47 base::ScopedPtrHashMap<uint32_t, scoped_ptr<std::string>>;
48 FontTableMap font_tables_;
50 SerializedFontDescription description_;
51 const PP_PrivateFontCharset charset_;
53 DISALLOW_COPY_AND_ASSIGN(FlashFontFileResource);
56 } // namespace proxy
57 } // namespace ppapi
59 #endif // PPAPI_PROXY_FLASH_FONT_FILE_RESOURCE_H_