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

Side by Side Diff: content/common/child_process_sandbox_support_impl_linux.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/child_process_sandbox_support_impl_linux.h" 5 #include "content/common/child_process_sandbox_support_impl_linux.h"
6 6
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/numerics/safe_conversions.h" 13 #include "base/numerics/safe_conversions.h"
14 #include "base/pickle.h" 14 #include "base/pickle.h"
15 #include "base/posix/eintr_wrapper.h" 15 #include "base/posix/eintr_wrapper.h"
16 #include "base/posix/unix_domain_socket_linux.h" 16 #include "base/posix/unix_domain_socket_linux.h"
17 #include "base/sys_byteorder.h" 17 #include "base/sys_byteorder.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "content/common/sandbox_linux/sandbox_linux.h" 19 #include "content/common/sandbox_linux/sandbox_linux.h"
20 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h" 20 #include "third_party/WebKit/public/platform/linux/WebFallbackFont.h"
21 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h" 21 #include "third_party/WebKit/public/platform/linux/WebFontRenderStyle.h"
22 22
23 namespace content { 23 namespace content {
24 24
25 void GetFallbackFontForCharacter(int32_t character, 25 void GetFallbackFontForCharacter(int32_t character,
26 const char* preferred_locale, 26 const char* preferred_locale,
27 blink::WebFallbackFont* fallbackFont) { 27 blink::WebFallbackFont* fallbackFont) {
28 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter"); 28 TRACE_EVENT0("sandbox_ipc", "GetFontFamilyForCharacter");
29 29
30 Pickle request; 30 base::Pickle request;
31 request.WriteInt(LinuxSandbox::METHOD_GET_FALLBACK_FONT_FOR_CHAR); 31 request.WriteInt(LinuxSandbox::METHOD_GET_FALLBACK_FONT_FOR_CHAR);
32 request.WriteInt(character); 32 request.WriteInt(character);
33 request.WriteString(preferred_locale); 33 request.WriteString(preferred_locale);
34 34
35 uint8_t buf[512]; 35 uint8_t buf[512];
36 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, 36 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
37 sizeof(buf), NULL, request); 37 sizeof(buf), NULL, request);
38 38
39 std::string family_name; 39 std::string family_name;
40 std::string filename; 40 std::string filename;
41 int fontconfigInterfaceId = 0; 41 int fontconfigInterfaceId = 0;
42 int ttcIndex = 0; 42 int ttcIndex = 0;
43 bool isBold = false; 43 bool isBold = false;
44 bool isItalic = false; 44 bool isItalic = false;
45 if (n != -1) { 45 if (n != -1) {
46 Pickle reply(reinterpret_cast<char*>(buf), n); 46 base::Pickle reply(reinterpret_cast<char*>(buf), n);
47 PickleIterator pickle_iter(reply); 47 base::PickleIterator pickle_iter(reply);
48 if (pickle_iter.ReadString(&family_name) && 48 if (pickle_iter.ReadString(&family_name) &&
49 pickle_iter.ReadString(&filename) && 49 pickle_iter.ReadString(&filename) &&
50 pickle_iter.ReadInt(&fontconfigInterfaceId) && 50 pickle_iter.ReadInt(&fontconfigInterfaceId) &&
51 pickle_iter.ReadInt(&ttcIndex) && 51 pickle_iter.ReadInt(&ttcIndex) &&
52 pickle_iter.ReadBool(&isBold) && 52 pickle_iter.ReadBool(&isBold) &&
53 pickle_iter.ReadBool(&isItalic)) { 53 pickle_iter.ReadBool(&isItalic)) {
54 fallbackFont->name = family_name; 54 fallbackFont->name = family_name;
55 fallbackFont->filename = filename; 55 fallbackFont->filename = filename;
56 fallbackFont->fontconfigInterfaceId = fontconfigInterfaceId; 56 fallbackFont->fontconfigInterfaceId = fontconfigInterfaceId;
57 fallbackFont->ttcIndex = ttcIndex; 57 fallbackFont->ttcIndex = ttcIndex;
(...skipping 12 matching lines...) Expand all
70 70
71 if (size_and_style < 0) 71 if (size_and_style < 0)
72 return; 72 return;
73 73
74 const bool bold = size_and_style & 1; 74 const bool bold = size_and_style & 1;
75 const bool italic = size_and_style & 2; 75 const bool italic = size_and_style & 2;
76 const int pixel_size = size_and_style >> 2; 76 const int pixel_size = size_and_style >> 2;
77 if (pixel_size > std::numeric_limits<uint16>::max()) 77 if (pixel_size > std::numeric_limits<uint16>::max())
78 return; 78 return;
79 79
80 Pickle request; 80 base::Pickle request;
81 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); 81 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
82 request.WriteString(family); 82 request.WriteString(family);
83 request.WriteBool(bold); 83 request.WriteBool(bold);
84 request.WriteBool(italic); 84 request.WriteBool(italic);
85 request.WriteUInt16(pixel_size); 85 request.WriteUInt16(pixel_size);
86 86
87 uint8_t buf[512]; 87 uint8_t buf[512];
88 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, 88 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
89 sizeof(buf), NULL, request); 89 sizeof(buf), NULL, request);
90 if (n == -1) 90 if (n == -1)
91 return; 91 return;
92 92
93 Pickle reply(reinterpret_cast<char*>(buf), n); 93 base::Pickle reply(reinterpret_cast<char*>(buf), n);
94 PickleIterator pickle_iter(reply); 94 base::PickleIterator pickle_iter(reply);
95 int use_bitmaps, use_autohint, use_hinting, hint_style, use_antialias; 95 int use_bitmaps, use_autohint, use_hinting, hint_style, use_antialias;
96 int use_subpixel_rendering, use_subpixel_positioning; 96 int use_subpixel_rendering, use_subpixel_positioning;
97 if (pickle_iter.ReadInt(&use_bitmaps) && 97 if (pickle_iter.ReadInt(&use_bitmaps) &&
98 pickle_iter.ReadInt(&use_autohint) && 98 pickle_iter.ReadInt(&use_autohint) &&
99 pickle_iter.ReadInt(&use_hinting) && 99 pickle_iter.ReadInt(&use_hinting) &&
100 pickle_iter.ReadInt(&hint_style) && 100 pickle_iter.ReadInt(&hint_style) &&
101 pickle_iter.ReadInt(&use_antialias) && 101 pickle_iter.ReadInt(&use_antialias) &&
102 pickle_iter.ReadInt(&use_subpixel_rendering) && 102 pickle_iter.ReadInt(&use_subpixel_rendering) &&
103 pickle_iter.ReadInt(&use_subpixel_positioning)) { 103 pickle_iter.ReadInt(&use_subpixel_positioning)) {
104 out->useBitmaps = use_bitmaps; 104 out->useBitmaps = use_bitmaps;
105 out->useAutoHint = use_autohint; 105 out->useAutoHint = use_autohint;
106 out->useHinting = use_hinting; 106 out->useHinting = use_hinting;
107 out->hintStyle = hint_style; 107 out->hintStyle = hint_style;
108 out->useAntiAlias = use_antialias; 108 out->useAntiAlias = use_antialias;
109 out->useSubpixelRendering = use_subpixel_rendering; 109 out->useSubpixelRendering = use_subpixel_rendering;
110 out->useSubpixelPositioning = use_subpixel_positioning; 110 out->useSubpixelPositioning = use_subpixel_positioning;
111 } 111 }
112 } 112 }
113 113
114 int MatchFontWithFallback(const std::string& face, 114 int MatchFontWithFallback(const std::string& face,
115 bool bold, 115 bool bold,
116 bool italic, 116 bool italic,
117 int charset, 117 int charset,
118 PP_BrowserFont_Trusted_Family fallback_family) { 118 PP_BrowserFont_Trusted_Family fallback_family) {
119 TRACE_EVENT0("sandbox_ipc", "MatchFontWithFallback"); 119 TRACE_EVENT0("sandbox_ipc", "MatchFontWithFallback");
120 120
121 Pickle request; 121 base::Pickle request;
122 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK); 122 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
123 request.WriteString(face); 123 request.WriteString(face);
124 request.WriteBool(bold); 124 request.WriteBool(bold);
125 request.WriteBool(italic); 125 request.WriteBool(italic);
126 request.WriteUInt32(charset); 126 request.WriteUInt32(charset);
127 request.WriteUInt32(fallback_family); 127 request.WriteUInt32(fallback_family);
128 uint8_t reply_buf[64]; 128 uint8_t reply_buf[64];
129 int fd = -1; 129 int fd = -1;
130 UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf, sizeof(reply_buf), 130 UnixDomainSocket::SendRecvMsg(GetSandboxFD(), reply_buf, sizeof(reply_buf),
131 &fd, request); 131 &fd, request);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset)); 198 ssize_t n = HANDLE_EINTR(pread(fd, output, data_length, data_offset));
199 if (n != base::checked_cast<ssize_t>(data_length)) 199 if (n != base::checked_cast<ssize_t>(data_length))
200 return false; 200 return false;
201 } 201 }
202 *output_length = data_length; 202 *output_length = data_length;
203 203
204 return true; 204 return true;
205 } 205 }
206 206
207 } // namespace content 207 } // namespace content
OLDNEW
« no previous file with comments | « content/common/cc_messages_unittest.cc ('k') | content/common/child_process_sandbox_support_impl_shm_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698