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

Unified Diff: content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc

Issue 337203003: Move PPB_TrueTypeFont_Dev host from renderer to browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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: content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc
diff --git a/content/renderer/pepper/pepper_truetype_font_linux.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc
similarity index 78%
rename from content/renderer/pepper/pepper_truetype_font_linux.cc
rename to content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc
index c54a5148a1a7a32b0fad447d38620702ac8f0dc7..9fe8814fb3eb90ad5ca7147478815a41cd492f49 100644
--- a/content/renderer/pepper/pepper_truetype_font_linux.cc
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_linux.cc
@@ -6,11 +6,11 @@
#include "base/memory/scoped_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/sys_byteorder.h"
+#include "content/browser/renderer_host/font_utils_linux.h"
+#include "content/browser/renderer_host/pepper/pepper_truetype_font.h"
#include "content/public/common/child_process_sandbox_support_linux.h"
-#include "content/renderer/pepper/pepper_truetype_font.h"
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
namespace content {
@@ -20,19 +20,20 @@ class PepperTrueTypeFontLinux : public PepperTrueTypeFont {
public:
explicit PepperTrueTypeFontLinux(
const ppapi::proxy::SerializedTrueTypeFontDesc& desc);
- virtual ~PepperTrueTypeFontLinux() OVERRIDE;
// PepperTrueTypeFont overrides.
- virtual bool IsValid() OVERRIDE;
- virtual int32_t Describe(ppapi::proxy::SerializedTrueTypeFontDesc* desc)
- OVERRIDE;
- virtual int32_t GetTableTags(std::vector<uint32_t>* tags) OVERRIDE;
+ virtual bool IsValid() const OVERRIDE;
+ virtual int32_t Describe(
+ ppapi::proxy::SerializedTrueTypeFontDesc* desc) const OVERRIDE;
+ virtual int32_t GetTableTags(std::vector<uint32_t>* tags) const OVERRIDE;
virtual int32_t GetTable(uint32_t table_tag,
int32_t offset,
int32_t max_data_length,
- std::string* data) OVERRIDE;
+ std::string* data) const OVERRIDE;
private:
+ virtual ~PepperTrueTypeFontLinux() OVERRIDE;
+
// Save creation parameters here and use these to implement Describe.
// TODO(bbudge) Modify content API to return results of font matching and
// fallback.
@@ -67,24 +68,28 @@ PepperTrueTypeFontLinux::PepperTrueTypeFontLinux(
}
}
- fd_ = MatchFontWithFallback(desc_.family.c_str(),
- desc_.weight >= PP_TRUETYPEFONTWEIGHT_BOLD,
- desc_.style & PP_TRUETYPEFONTSTYLE_ITALIC,
- desc_.charset,
- PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT);
+ fd_ = MatchFontFaceWithFallback(desc_.family,
+ desc_.weight >= PP_TRUETYPEFONTWEIGHT_BOLD,
+ desc_.style & PP_TRUETYPEFONTSTYLE_ITALIC,
+ desc_.charset,
+ PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT);
piman 2014/06/19 20:03:42 If I'm not mistaken, this is happening on the IO t
bbudge 2014/06/21 14:12:50 Done. On the blocking pool.
}
-PepperTrueTypeFontLinux::~PepperTrueTypeFontLinux() {}
+PepperTrueTypeFontLinux::~PepperTrueTypeFontLinux() {
+}
-bool PepperTrueTypeFontLinux::IsValid() { return fd_ != -1; }
+bool PepperTrueTypeFontLinux::IsValid() const {
+ return fd_ != -1;
+}
int32_t PepperTrueTypeFontLinux::Describe(
- ppapi::proxy::SerializedTrueTypeFontDesc* desc) {
+ ppapi::proxy::SerializedTrueTypeFontDesc* desc) const {
*desc = desc_;
return PP_OK;
}
-int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector<uint32_t>* tags) {
+int32_t PepperTrueTypeFontLinux::GetTableTags(
+ std::vector<uint32_t>* tags) const {
// Get the 2 byte numTables field at an offset of 4 in the font.
uint8_t num_tables_buf[2];
size_t output_length = sizeof(num_tables_buf);
@@ -128,7 +133,7 @@ int32_t PepperTrueTypeFontLinux::GetTableTags(std::vector<uint32_t>* tags) {
int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag,
int32_t offset,
int32_t max_data_length,
- std::string* data) {
+ std::string* data) const {
// Get the size of the font data first.
size_t table_size = 0;
// Tags are byte swapped on Linux.
@@ -151,9 +156,12 @@ int32_t PepperTrueTypeFontLinux::GetTable(uint32_t table_tag,
} // namespace
// static
-PepperTrueTypeFont* PepperTrueTypeFont::Create(
+scoped_refptr<PepperTrueTypeFont> PepperTrueTypeFont::Create(
const ppapi::proxy::SerializedTrueTypeFontDesc& desc) {
- return new PepperTrueTypeFontLinux(desc);
+ scoped_refptr<PepperTrueTypeFont> font = new PepperTrueTypeFontLinux(desc);
+ if (!font->IsValid())
+ font = NULL;
+ return font;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698