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

Side by Side Diff: chrome/common/font_config_ipc_linux.cc

Issue 6677096: Move a bunch of files from chrome\common to content\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | « chrome/common/font_config_ipc_linux.h ('k') | chrome/common/geoposition.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/font_config_ipc_linux.h"
6
7 #include <errno.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #include <sys/socket.h>
11 #include <sys/uio.h>
12
13 #include "base/pickle.h"
14 #include "chrome/common/unix_domain_socket_posix.h"
15
16 FontConfigIPC::FontConfigIPC(int fd)
17 : fd_(fd) {
18 }
19
20 FontConfigIPC::~FontConfigIPC() {
21 close(fd_);
22 }
23
24 bool FontConfigIPC::Match(std::string* result_family,
25 unsigned* result_filefaceid,
26 bool filefaceid_valid, unsigned filefaceid,
27 const std::string& family,
28 const void* characters, size_t characters_bytes,
29 bool* is_bold, bool* is_italic) {
30 if (family.length() > kMaxFontFamilyLength)
31 return false;
32
33 Pickle request;
34 request.WriteInt(METHOD_MATCH);
35 request.WriteBool(filefaceid_valid);
36 if (filefaceid_valid)
37 request.WriteUInt32(filefaceid);
38
39 request.WriteBool(is_bold && *is_bold);
40 request.WriteBool(is_bold && *is_italic);
41
42 request.WriteUInt32(characters_bytes);
43 if (characters_bytes)
44 request.WriteBytes(characters, characters_bytes);
45
46 request.WriteString(family);
47
48 uint8_t reply_buf[512];
49 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
50 sizeof(reply_buf), NULL,
51 request);
52 if (r == -1)
53 return false;
54
55 Pickle reply(reinterpret_cast<char*>(reply_buf), r);
56 void* iter = NULL;
57 bool result;
58 if (!reply.ReadBool(&iter, &result))
59 return false;
60 if (!result)
61 return false;
62
63 uint32_t reply_filefaceid;
64 std::string reply_family;
65 bool resulting_bold, resulting_italic;
66 if (!reply.ReadUInt32(&iter, &reply_filefaceid) ||
67 !reply.ReadString(&iter, &reply_family) ||
68 !reply.ReadBool(&iter, &resulting_bold) ||
69 !reply.ReadBool(&iter, &resulting_italic)) {
70 return false;
71 }
72
73 *result_filefaceid = reply_filefaceid;
74 if (result_family)
75 *result_family = reply_family;
76
77 if (is_bold)
78 *is_bold = resulting_bold;
79 if (is_italic)
80 *is_italic = resulting_italic;
81
82 return true;
83 }
84
85 int FontConfigIPC::Open(unsigned filefaceid) {
86 Pickle request;
87 request.WriteInt(METHOD_OPEN);
88 request.WriteUInt32(filefaceid);
89
90 int result_fd = -1;
91 uint8_t reply_buf[256];
92 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
93 sizeof(reply_buf),
94 &result_fd, request);
95
96 if (r == -1)
97 return -1;
98
99 Pickle reply(reinterpret_cast<char*>(reply_buf), r);
100 bool result;
101 void* iter = NULL;
102 if (!reply.ReadBool(&iter, &result) ||
103 !result) {
104 if (result_fd)
105 close(result_fd);
106 return -1;
107 }
108
109 return result_fd;
110 }
OLDNEW
« no previous file with comments | « chrome/common/font_config_ipc_linux.h ('k') | chrome/common/geoposition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698