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.
5 #ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_
6 #define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_
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"
13 namespace font_service
{
16 // Owns the memory of the mmaped file that we get back from the font_service.
18 // This class is an implementation detail and shouldn't be used by consumers.
19 class MappedFontFile
: public base::RefCountedThreadSafe
<MappedFontFile
> {
25 // Called when a MappedFontFile is destroyed.
26 virtual void OnMappedFontFileDestroyed(MappedFontFile
* f
) = 0;
29 explicit MappedFontFile(uint32_t font_id
);
31 uint32_t font_id() const { return font_id_
; }
33 void set_observer(Observer
* observer
) { observer_
= observer
; }
35 bool Initialize(base::File file
);
37 SkMemoryStream
* CreateMemoryStream();
40 friend class base::RefCountedThreadSafe
<MappedFontFile
>;
44 static void ReleaseProc(const void* ptr
, void* context
);
47 base::MemoryMappedFile mapped_font_file_
;
51 } // namespace internal
52 } // namespace font_service
54 #endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_