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

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

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/zygote_main_linux.cc ('k') | content/common/clipboard_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 "base/eintr_wrapper.h" 9 #include "base/eintr_wrapper.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/pickle.h" 11 #include "base/pickle.h"
(...skipping 17 matching lines...) Expand all
29 29
30 uint8_t buf[512]; 30 uint8_t buf[512];
31 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, 31 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
32 sizeof(buf), NULL, request); 32 sizeof(buf), NULL, request);
33 33
34 std::string family_name; 34 std::string family_name;
35 bool isBold = false; 35 bool isBold = false;
36 bool isItalic = false; 36 bool isItalic = false;
37 if (n != -1) { 37 if (n != -1) {
38 Pickle reply(reinterpret_cast<char*>(buf), n); 38 Pickle reply(reinterpret_cast<char*>(buf), n);
39 void* pickle_iter = NULL; 39 PickleIterator pickle_iter(reply);
40 if (reply.ReadString(&pickle_iter, &family_name) && 40 if (reply.ReadString(&pickle_iter, &family_name) &&
41 reply.ReadBool(&pickle_iter, &isBold) && 41 reply.ReadBool(&pickle_iter, &isBold) &&
42 reply.ReadBool(&pickle_iter, &isItalic)) { 42 reply.ReadBool(&pickle_iter, &isItalic)) {
43 family->name = family_name; 43 family->name = family_name;
44 family->isBold = isBold; 44 family->isBold = isBold;
45 family->isItalic = isItalic; 45 family->isItalic = isItalic;
46 } 46 }
47 } 47 }
48 } 48 }
49 49
50 void GetRenderStyleForStrike(const char* family, int sizeAndStyle, 50 void GetRenderStyleForStrike(const char* family, int sizeAndStyle,
51 WebKit::WebFontRenderStyle* out) { 51 WebKit::WebFontRenderStyle* out) {
52 Pickle request; 52 Pickle request;
53 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE); 53 request.WriteInt(LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE);
54 request.WriteString(family); 54 request.WriteString(family);
55 request.WriteInt(sizeAndStyle); 55 request.WriteInt(sizeAndStyle);
56 56
57 uint8_t buf[512]; 57 uint8_t buf[512];
58 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf, 58 const ssize_t n = UnixDomainSocket::SendRecvMsg(GetSandboxFD(), buf,
59 sizeof(buf), NULL, request); 59 sizeof(buf), NULL, request);
60 60
61 out->setDefaults(); 61 out->setDefaults();
62 if (n == -1) { 62 if (n == -1) {
63 return; 63 return;
64 } 64 }
65 65
66 Pickle reply(reinterpret_cast<char*>(buf), n); 66 Pickle reply(reinterpret_cast<char*>(buf), n);
67 void* pickle_iter = NULL; 67 PickleIterator pickle_iter(reply);
68 int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel; 68 int useBitmaps, useAutoHint, useHinting, hintStyle, useAntiAlias, useSubpixel;
69 if (reply.ReadInt(&pickle_iter, &useBitmaps) && 69 if (reply.ReadInt(&pickle_iter, &useBitmaps) &&
70 reply.ReadInt(&pickle_iter, &useAutoHint) && 70 reply.ReadInt(&pickle_iter, &useAutoHint) &&
71 reply.ReadInt(&pickle_iter, &useHinting) && 71 reply.ReadInt(&pickle_iter, &useHinting) &&
72 reply.ReadInt(&pickle_iter, &hintStyle) && 72 reply.ReadInt(&pickle_iter, &hintStyle) &&
73 reply.ReadInt(&pickle_iter, &useAntiAlias) && 73 reply.ReadInt(&pickle_iter, &useAntiAlias) &&
74 reply.ReadInt(&pickle_iter, &useSubpixel)) { 74 reply.ReadInt(&pickle_iter, &useSubpixel)) {
75 out->useBitmaps = useBitmaps; 75 out->useBitmaps = useBitmaps;
76 out->useAutoHint = useAutoHint; 76 out->useAutoHint = useAutoHint;
77 out->useHinting = useHinting; 77 out->useHinting = useHinting;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 *output_length = length; 168 *output_length = length;
169 n = HANDLE_EINTR(pread(fd, output, length, offset)); 169 n = HANDLE_EINTR(pread(fd, output, length, offset));
170 if (n != static_cast<ssize_t>(length)) 170 if (n != static_cast<ssize_t>(length))
171 return false; 171 return false;
172 172
173 return true; 173 return true;
174 } 174 }
175 175
176 } // namespace content 176 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/zygote_main_linux.cc ('k') | content/common/clipboard_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698