| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_ | |
| 6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_ | |
| 7 | |
| 8 #include "base/files/file.h" | |
| 9 #include "base/files/memory_mapped_file.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "third_party/skia/include/core/SkStream.h" | |
| 12 | |
| 13 namespace font_service { | |
| 14 namespace internal { | |
| 15 | |
| 16 // Owns the memory of the mmaped file that we get back from the font_service. | |
| 17 // | |
| 18 // This class is an implementation detail and shouldn't be used by consumers. | |
| 19 class MappedFontFile : public base::RefCountedThreadSafe<MappedFontFile> { | |
| 20 public: | |
| 21 class Observer { | |
| 22 public: | |
| 23 ~Observer() {} | |
| 24 | |
| 25 // Called when a MappedFontFile is destroyed. | |
| 26 virtual void OnMappedFontFileDestroyed(MappedFontFile* f) = 0; | |
| 27 }; | |
| 28 | |
| 29 explicit MappedFontFile(uint32_t font_id); | |
| 30 | |
| 31 uint32_t font_id() const { return font_id_; } | |
| 32 | |
| 33 void set_observer(Observer* observer) { observer_ = observer; } | |
| 34 | |
| 35 bool Initialize(base::File file); | |
| 36 | |
| 37 SkMemoryStream* CreateMemoryStream(); | |
| 38 | |
| 39 private: | |
| 40 friend class base::RefCountedThreadSafe<MappedFontFile>; | |
| 41 | |
| 42 ~MappedFontFile(); | |
| 43 | |
| 44 static void ReleaseProc(const void* ptr, void* context); | |
| 45 | |
| 46 uint32_t font_id_; | |
| 47 base::MemoryMappedFile mapped_font_file_; | |
| 48 Observer* observer_; | |
| 49 }; | |
| 50 | |
| 51 } // namespace internal | |
| 52 } // namespace font_service | |
| 53 | |
| 54 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_ | |
| OLD | NEW |