| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ | 5 #ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ |
| 6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ | 6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public internal::MappedFontFile::Observer { | 36 public internal::MappedFontFile::Observer { |
| 37 public: | 37 public: |
| 38 explicit FontLoader(mojo::Connector* connector); | 38 explicit FontLoader(mojo::Connector* connector); |
| 39 ~FontLoader() override; | 39 ~FontLoader() override; |
| 40 | 40 |
| 41 // Shuts down the background thread. | 41 // Shuts down the background thread. |
| 42 void Shutdown(); | 42 void Shutdown(); |
| 43 | 43 |
| 44 // SkFontConfigInterface: | 44 // SkFontConfigInterface: |
| 45 bool matchFamilyName(const char family_name[], | 45 bool matchFamilyName(const char family_name[], |
| 46 SkTypeface::Style requested, | 46 SkFontStyle requested, |
| 47 FontIdentity* out_font_identifier, | 47 FontIdentity* out_font_identifier, |
| 48 SkString* out_family_name, | 48 SkString* out_family_name, |
| 49 SkTypeface::Style* out_style) override; | 49 SkFontStyle* out_style) override; |
| 50 SkStreamAsset* openStream(const FontIdentity& identity) override; | 50 SkStreamAsset* openStream(const FontIdentity& identity) override; |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 // internal::MappedFontFile::Observer: | 53 // internal::MappedFontFile::Observer: |
| 54 void OnMappedFontFileDestroyed(internal::MappedFontFile* f) override; | 54 void OnMappedFontFileDestroyed(internal::MappedFontFile* f) override; |
| 55 | 55 |
| 56 // Thread to own the mojo message pipe. Because FontLoader can be called on | 56 // Thread to own the mojo message pipe. Because FontLoader can be called on |
| 57 // multiple threads, we create a dedicated thread to send and receive mojo | 57 // multiple threads, we create a dedicated thread to send and receive mojo |
| 58 // message calls. | 58 // message calls. |
| 59 scoped_refptr<internal::FontServiceThread> thread_; | 59 scoped_refptr<internal::FontServiceThread> thread_; |
| 60 | 60 |
| 61 // Lock preventing multiple threads from opening font file and accessing | 61 // Lock preventing multiple threads from opening font file and accessing |
| 62 // |mapped_font_files_| map at the same time. | 62 // |mapped_font_files_| map at the same time. |
| 63 base::Lock lock_; | 63 base::Lock lock_; |
| 64 | 64 |
| 65 // Maps font identity ID to the memory-mapped file with font data. | 65 // Maps font identity ID to the memory-mapped file with font data. |
| 66 base::hash_map<uint32_t, internal::MappedFontFile*> mapped_font_files_; | 66 base::hash_map<uint32_t, internal::MappedFontFile*> mapped_font_files_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(FontLoader); | 68 DISALLOW_COPY_AND_ASSIGN(FontLoader); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 } // namespace font_service | 71 } // namespace font_service |
| 72 | 72 |
| 73 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ | 73 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_ |
| OLD | NEW |