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 CONTENT_COMMON_FONT_CONFIG_IPC_LINUX_H_
6 #define CONTENT_COMMON_FONT_CONFIG_IPC_LINUX_H_
8 #include "base/compiler_specific.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/synchronization/lock.h"
11 #include "third_party/skia/include/core/SkStream.h"
12 #include "third_party/skia/include/core/SkTypeface.h"
13 #include "third_party/skia/include/ports/SkFontConfigInterface.h"
21 // FontConfig implementation for Skia that proxies out of process to get out
22 // of the sandbox. See http://code.google.com/p/chromium/wiki/LinuxSandboxIPC
23 class FontConfigIPC
: public SkFontConfigInterface
{
25 explicit FontConfigIPC(int fd
);
26 ~FontConfigIPC() override
;
28 bool matchFamilyName(const char familyName
[],
29 SkTypeface::Style requested
,
30 FontIdentity
* outFontIdentifier
,
31 SkString
* outFamilyName
,
32 SkTypeface::Style
* outStyle
) override
;
34 SkStreamAsset
* openStream(const FontIdentity
&) override
;
42 kMaxFontFamilyLength
= 2048
48 // Removes |mapped_font_file| from |mapped_font_files_|.
49 // Does not delete the passed-in object.
50 void RemoveMappedFontFile(MappedFontFile
* mapped_font_file
);
53 // Lock preventing multiple threads from opening font file and accessing
54 // |mapped_font_files_| map at the same time.
56 // Maps font identity ID to the memory-mapped file with font data.
57 base::hash_map
<uint32_t, MappedFontFile
*> mapped_font_files_
;
60 } // namespace content
62 #endif // CONTENT_COMMON_FONT_CONFIG_IPC_LINUX_H_