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

Unified Diff: components/font_service/public/cpp/mapped_font_file.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
Index: components/font_service/public/cpp/mapped_font_file.h
diff --git a/components/font_service/public/cpp/mapped_font_file.h b/components/font_service/public/cpp/mapped_font_file.h
new file mode 100644
index 0000000000000000000000000000000000000000..c860fed4c3d501ef39624d87b0f4de028585c60c
--- /dev/null
+++ b/components/font_service/public/cpp/mapped_font_file.h
@@ -0,0 +1,54 @@
+// 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_MAPPED_FONT_FILE_H_
+#define COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_
+
+#include "base/files/file.h"
+#include "base/files/memory_mapped_file.h"
+#include "base/memory/ref_counted.h"
+#include "third_party/skia/include/core/SkStream.h"
+
+namespace font_service {
+namespace internal {
+
+// Owns the memory of the mmaped file that we get back from the font_service.
+//
+// This class is an implementation detail and shouldn't be used by consumers.
+class MappedFontFile : public base::RefCountedThreadSafe<MappedFontFile> {
+ public:
+ class Observer {
+ public:
+ ~Observer() {}
+
+ // Called when a MappedFontFile is destroyed.
+ virtual void OnMappedFontFileDestroyed(MappedFontFile* f) = 0;
+ };
+
+ explicit MappedFontFile(uint32_t font_id);
+
+ uint32_t font_id() const { return font_id_; }
+
+ void set_observer(Observer* observer) { observer_ = observer; }
+
+ bool Initialize(base::File file);
+
+ SkMemoryStream* CreateMemoryStream();
+
+ private:
+ friend class base::RefCountedThreadSafe<MappedFontFile>;
+
+ ~MappedFontFile();
+
+ static void ReleaseProc(const void* ptr, void* context);
+
+ uint32_t font_id_;
+ base::MemoryMappedFile mapped_font_file_;
+ Observer* observer_;
+};
+
+} // namespace internal
+} // namespace font_service
+
+#endif // COMPONENTS_FONT_SERVICE_PUBLIC_CPP_MAPPED_FONT_FILE_H_
« no previous file with comments | « components/font_service/public/cpp/font_service_thread.cc ('k') | components/font_service/public/cpp/mapped_font_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698