OLD | NEW |
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/font_config_ipc_linux.h" | 5 #include "content/common/font_config_ipc_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/mman.h> | 9 #include <sys/mman.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 uint8_t reply_buf[2048]; | 63 uint8_t reply_buf[2048]; |
64 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, | 64 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, |
65 sizeof(reply_buf), NULL, | 65 sizeof(reply_buf), NULL, |
66 request); | 66 request); |
67 if (r == -1) | 67 if (r == -1) |
68 return false; | 68 return false; |
69 | 69 |
70 Pickle reply(reinterpret_cast<char*>(reply_buf), r); | 70 Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
71 PickleIterator iter(reply); | 71 PickleIterator iter(reply); |
72 bool result; | 72 bool result; |
73 if (!reply.ReadBool(&iter, &result)) | 73 if (!iter.ReadBool(&result)) |
74 return false; | 74 return false; |
75 if (!result) | 75 if (!result) |
76 return false; | 76 return false; |
77 | 77 |
78 SkString reply_family; | 78 SkString reply_family; |
79 FontIdentity reply_identity; | 79 FontIdentity reply_identity; |
80 uint32_t reply_style; | 80 uint32_t reply_style; |
81 if (!skia::ReadSkString(reply, &iter, &reply_family) || | 81 if (!skia::ReadSkString(&iter, &reply_family) || |
82 !skia::ReadSkFontIdentity(reply, &iter, &reply_identity) || | 82 !skia::ReadSkFontIdentity(&iter, &reply_identity) || |
83 !reply.ReadUInt32(&iter, &reply_style)) { | 83 !iter.ReadUInt32(&reply_style)) { |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 if (outFontIdentity) | 87 if (outFontIdentity) |
88 *outFontIdentity = reply_identity; | 88 *outFontIdentity = reply_identity; |
89 if (outFamilyName) | 89 if (outFamilyName) |
90 *outFamilyName = reply_family; | 90 *outFamilyName = reply_family; |
91 if (outStyle) | 91 if (outStyle) |
92 *outStyle = static_cast<SkTypeface::Style>(reply_style); | 92 *outStyle = static_cast<SkTypeface::Style>(reply_style); |
93 | 93 |
(...skipping 11 matching lines...) Expand all Loading... |
105 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, | 105 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, |
106 sizeof(reply_buf), | 106 sizeof(reply_buf), |
107 &result_fd, request); | 107 &result_fd, request); |
108 | 108 |
109 if (r == -1) | 109 if (r == -1) |
110 return NULL; | 110 return NULL; |
111 | 111 |
112 Pickle reply(reinterpret_cast<char*>(reply_buf), r); | 112 Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
113 bool result; | 113 bool result; |
114 PickleIterator iter(reply); | 114 PickleIterator iter(reply); |
115 if (!reply.ReadBool(&iter, &result) || | 115 if (!iter.ReadBool(&result) || !result) { |
116 !result) { | |
117 if (result_fd) | 116 if (result_fd) |
118 CloseFD(result_fd); | 117 CloseFD(result_fd); |
119 return NULL; | 118 return NULL; |
120 } | 119 } |
121 | 120 |
122 SkStream* stream = StreamFromFD(result_fd); | 121 SkStream* stream = StreamFromFD(result_fd); |
123 CloseFD(result_fd); | 122 CloseFD(result_fd); |
124 return stream; | 123 return stream; |
125 } | 124 } |
126 | 125 |
127 } // namespace content | 126 } // namespace content |
128 | 127 |
OLD | NEW |