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

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

Issue 8893009: Move content::MakeSharedMemorySegmentViaIPC into its own file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: back to like patch set 3 Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/global_descriptors_posix.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/pickle.h" 11 #include "base/pickle.h"
13 #include "content/common/chrome_descriptors.h" 12 #include "content/common/child_process_sandbox_support_impl_linux.h"
jam 2011/12/15 01:08:31 nit: redundant
14 #include "content/common/sandbox_methods_linux.h" 13 #include "content/common/sandbox_methods_linux.h"
15 #include "content/common/unix_domain_socket_posix.h" 14 #include "content/common/unix_domain_socket_posix.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon tFamily.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/linux/WebFon tFamily.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderSt yle.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderSt yle.h"
18 17
19 static int GetSandboxFD() {
20 return kSandboxIPCChannel + base::GlobalDescriptors::kBaseDescriptor;
21 }
22
23 namespace content { 18 namespace content {
24 19
25 void GetFontFamilyForCharacters(const uint16_t* utf16, 20 void GetFontFamilyForCharacters(const uint16_t* utf16,
26 size_t num_utf16, 21 size_t num_utf16,
27 const char* preferred_locale, 22 const char* preferred_locale,
28 WebKit::WebFontFamily* family) { 23 WebKit::WebFontFamily* family) {
29 Pickle request; 24 Pickle request;
30 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS); 25 request.WriteInt(LinuxSandbox::METHOD_GET_FONT_FAMILY_FOR_CHARS);
31 request.WriteInt(num_utf16); 26 request.WriteInt(num_utf16);
32 for (size_t i = 0; i < num_utf16; ++i) 27 for (size_t i = 0; i < num_utf16; ++i)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 reply.ReadInt(&pickle_iter, &useSubpixel)) { 75 reply.ReadInt(&pickle_iter, &useSubpixel)) {
81 out->useBitmaps = useBitmaps; 76 out->useBitmaps = useBitmaps;
82 out->useAutoHint = useAutoHint; 77 out->useAutoHint = useAutoHint;
83 out->useHinting = useHinting; 78 out->useHinting = useHinting;
84 out->hintStyle = hintStyle; 79 out->hintStyle = hintStyle;
85 out->useAntiAlias = useAntiAlias; 80 out->useAntiAlias = useAntiAlias;
86 out->useSubpixel = useSubpixel; 81 out->useSubpixel = useSubpixel;
87 } 82 }
88 } 83 }
89 84
90 int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) {
91 Pickle request;
92 request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT);
93 request.WriteUInt32(length);
94 request.WriteBool(executable);
95 uint8_t reply_buf[10];
96 int result_fd;
97 ssize_t result = UnixDomainSocket::SendRecvMsg(GetSandboxFD(),
98 reply_buf, sizeof(reply_buf),
99 &result_fd, request);
100 if (result == -1)
101 return -1;
102 return result_fd;
103 }
104
105 int MatchFontWithFallback(const std::string& face, bool bold, 85 int MatchFontWithFallback(const std::string& face, bool bold,
106 bool italic, int charset) { 86 bool italic, int charset) {
107 Pickle request; 87 Pickle request;
108 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK); 88 request.WriteInt(LinuxSandbox::METHOD_MATCH_WITH_FALLBACK);
109 request.WriteString(face); 89 request.WriteString(face);
110 request.WriteBool(bold); 90 request.WriteBool(bold);
111 request.WriteBool(italic); 91 request.WriteBool(italic);
112 request.WriteUInt32(charset); 92 request.WriteUInt32(charset);
113 uint8_t reply_buf[64]; 93 uint8_t reply_buf[64];
114 int fd = -1; 94 int fd = -1;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 168
189 *output_length = length; 169 *output_length = length;
190 n = HANDLE_EINTR(pread(fd, output, length, offset)); 170 n = HANDLE_EINTR(pread(fd, output, length, offset));
191 if (n != static_cast<ssize_t>(length)) 171 if (n != static_cast<ssize_t>(length))
192 return false; 172 return false;
193 173
194 return true; 174 return true;
195 } 175 }
196 176
197 } // namespace content 177 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698