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

Unified Diff: content/child/child_process_sandbox_support_impl_linux.cc

Issue 2679323006: Remove content/browser dependency on WebFontRenderStyle. (Closed)
Patch Set: merge Created 3 years, 10 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/child/child_process_sandbox_support_impl_linux.cc
diff --git a/content/common/child_process_sandbox_support_impl_linux.cc b/content/child/child_process_sandbox_support_impl_linux.cc
similarity index 55%
rename from content/common/child_process_sandbox_support_impl_linux.cc
rename to content/child/child_process_sandbox_support_impl_linux.cc
index 928344ac840510e07a642c7689b236d876a4d0d1..a4d108318c5840fa19cba59dd420e56b44c3c647 100644
--- a/content/common/child_process_sandbox_support_impl_linux.cc
+++ b/content/child/child_process_sandbox_support_impl_linux.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2017 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.
-#include "content/common/child_process_sandbox_support_impl_linux.h"
+#include "content/child/child_process_sandbox_support_impl_linux.h"
#include <stddef.h>
#include <sys/stat.h>
@@ -10,7 +10,6 @@
#include <limits>
#include <memory>
-#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/unix_domain_socket_linux.h"
@@ -48,8 +47,7 @@ void GetFallbackFontForCharacter(int32_t character,
if (pickle_iter.ReadString(&family_name) &&
pickle_iter.ReadString(&filename) &&
pickle_iter.ReadInt(&fontconfigInterfaceId) &&
- pickle_iter.ReadInt(&ttcIndex) &&
- pickle_iter.ReadBool(&isBold) &&
+ pickle_iter.ReadInt(&ttcIndex) && pickle_iter.ReadBool(&isBold) &&
pickle_iter.ReadBool(&isItalic)) {
fallbackFont->name = family_name;
fallbackFont->filename = filename;
@@ -94,10 +92,8 @@ void GetRenderStyleForStrike(const char* family,
base::PickleIterator pickle_iter(reply);
int use_bitmaps, use_autohint, use_hinting, hint_style, use_antialias;
int use_subpixel_rendering, use_subpixel_positioning;
- if (pickle_iter.ReadInt(&use_bitmaps) &&
- pickle_iter.ReadInt(&use_autohint) &&
- pickle_iter.ReadInt(&use_hinting) &&
- pickle_iter.ReadInt(&hint_style) &&
+ if (pickle_iter.ReadInt(&use_bitmaps) && pickle_iter.ReadInt(&use_autohint) &&
+ pickle_iter.ReadInt(&use_hinting) && pickle_iter.ReadInt(&hint_style) &&
pickle_iter.ReadInt(&use_antialias) &&
pickle_iter.ReadInt(&use_subpixel_rendering) &&
pickle_iter.ReadInt(&use_subpixel_positioning)) {
@@ -127,81 +123,9 @@ int MatchFontWithFallback(const std::string& face,
request.WriteUInt32(fallback_family);
uint8_t reply_buf[64];
int fd = -1;
- base::UnixDomainSocket::SendRecvMsg(
- GetSandboxFD(), reply_buf, sizeof(reply_buf), &fd, request);
+ base::UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf,
+ sizeof(reply_buf), &fd, request);
return fd;
}
-bool GetFontTable(int fd, uint32_t table_tag, off_t offset,
- uint8_t* output, size_t* output_length) {
- if (offset < 0)
- return false;
-
- size_t data_length = 0; // the length of the file data.
- off_t data_offset = 0; // the offset of the data in the file.
- if (table_tag == 0) {
- // Get the entire font file.
- struct stat st;
- if (fstat(fd, &st) < 0)
- return false;
- data_length = base::checked_cast<size_t>(st.st_size);
- } else {
- // Get a font table. Read the header to find its offset in the file.
- uint16_t num_tables;
- ssize_t n = HANDLE_EINTR(pread(fd, &num_tables, sizeof(num_tables),
- 4 /* skip the font type */));
- if (n != sizeof(num_tables))
- return false;
- // Font data is stored in net (big-endian) order.
- num_tables = base::NetToHost16(num_tables);
-
- // Read the table directory.
- static const size_t kTableEntrySize = 16;
- const size_t directory_size = num_tables * kTableEntrySize;
- std::unique_ptr<uint8_t[]> table_entries(new uint8_t[directory_size]);
- n = HANDLE_EINTR(pread(fd, table_entries.get(), directory_size,
- 12 /* skip the SFNT header */));
- if (n != base::checked_cast<ssize_t>(directory_size))
- return false;
-
- for (uint16_t i = 0; i < num_tables; ++i) {
- uint8_t* entry = table_entries.get() + i * kTableEntrySize;
- uint32_t tag = *reinterpret_cast<uint32_t*>(entry);
- if (tag == table_tag) {
- // Font data is stored in net (big-endian) order.
- data_offset =
- base::NetToHost32(*reinterpret_cast<uint32_t*>(entry + 8));
- data_length =
- base::NetToHost32(*reinterpret_cast<uint32_t*>(entry + 12));
- break;
- }
- }
- }
-
- if (!data_length)
- return false;
- // Clamp |offset| inside the allowable range. This allows the read to succeed
- // but return 0 bytes.
- offset = std::min(offset, base::checked_cast<off_t>(data_length));
- // Make sure it's safe to add the data offset and the caller's logical offset.
- // Define the maximum positive offset on 32 bit systems.
- static const off_t kMaxPositiveOffset32 = 0x7FFFFFFF; // 2 GB - 1.
- if ((offset > kMaxPositiveOffset32 / 2) ||
- (data_offset > kMaxPositiveOffset32 / 2))
- return false;
- data_offset += offset;
- data_length -= offset;
-
- if (output) {
- // 'output_length' holds the maximum amount of data the caller can accept.
- data_length = std::min(data_length, *output_length);
- ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset));
- if (n != base::checked_cast<ssize_t>(data_length))
- return false;
- }
- *output_length = data_length;
-
- return true;
-}
-
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698