Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: components/font_service/public/cpp/font_loader.h

Issue 1280043003: Sandbox html_viewer on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update DEPS for the new dependency. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/font_service/public/cpp/BUILD.gn ('k') | components/font_service/public/cpp/font_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/font_service/public/cpp/font_loader.h
diff --git a/components/font_service/public/cpp/font_loader.h b/components/font_service/public/cpp/font_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..38e82e10283753e4a8a909f93bc2e2a7b67140d8
--- /dev/null
+++ b/components/font_service/public/cpp/font_loader.h
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_
+#define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_
+
+#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "components/font_service/public/cpp/mapped_font_file.h"
+#include "components/font_service/public/interfaces/font_service.mojom.h"
+#include "third_party/skia/include/core/SkStream.h"
+#include "third_party/skia/include/core/SkTypeface.h"
+#include "third_party/skia/include/ports/SkFontConfigInterface.h"
+
+namespace mojo {
+class ApplicationImpl;
+}
+
+namespace font_service {
+namespace internal {
+class FontServiceThread;
+}
+
+// FontConfig implementation for Skia which proxies to the font service to get
+// out of the sandbox. This methods of this class (as imposed by blink
+// requirements) may be called on any thread. (Because of this restriction,
+// also see the FontServiceThread class.)
+//
+// This is the mojo equivalent to content/common/font_config_ipc_linux.h
+class FontLoader : public SkFontConfigInterface,
+ public internal::MappedFontFile::Observer {
+ public:
+ explicit FontLoader(mojo::ApplicationImpl* application_impl);
+ ~FontLoader() override;
+
+ // SkFontConfigInterface:
+ bool matchFamilyName(const char family_name[],
+ SkTypeface::Style requested,
+ FontIdentity* out_font_identifier,
+ SkString* out_family_name,
+ SkTypeface::Style* out_style) override;
+ SkStreamAsset* openStream(const FontIdentity& identity) override;
+
+ private:
+ // internal::MappedFontFile::Observer:
+ void OnMappedFontFileDestroyed(internal::MappedFontFile* f) override;
+
+ // Thread to own the mojo message pipe. Because FontLoader can be called on
+ // multiple threads, we create a dedicated thread to send and receive mojo
+ // message calls.
+ scoped_refptr<internal::FontServiceThread> thread_;
+
+ // Lock preventing multiple threads from opening font file and accessing
+ // |mapped_font_files_| map at the same time.
+ base::Lock lock_;
+
+ // Maps font identity ID to the memory-mapped file with font data.
+ base::hash_map<uint32_t, internal::MappedFontFile*> mapped_font_files_;
+
+ DISALLOW_COPY_AND_ASSIGN(FontLoader);
+};
+
+} // namespace font_service
+
+#endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_FONT_LOADER_H_
« no previous file with comments | « components/font_service/public/cpp/BUILD.gn ('k') | components/font_service/public/cpp/font_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698