Update V8 to version 4.6.72.
[chromium-blink-merge.git] / content / common / font_config_ipc_linux.h
blobcbdabbeb1c9493358e70d696aefbc1f05a940989
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"
15 #include <string>
17 class SkString;
19 namespace content {
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 {
24 public:
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;
36 enum Method {
37 METHOD_MATCH = 0,
38 METHOD_OPEN = 1,
41 enum {
42 kMaxFontFamilyLength = 2048
45 private:
46 class MappedFontFile;
48 // Removes |mapped_font_file| from |mapped_font_files_|.
49 // Does not delete the passed-in object.
50 void RemoveMappedFontFile(MappedFontFile* mapped_font_file);
52 const int fd_;
53 // Lock preventing multiple threads from opening font file and accessing
54 // |mapped_font_files_| map at the same time.
55 base::Lock lock_;
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_