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

Side by Side Diff: content/common/font_config_ipc_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
« no previous file with comments | « content/common/cursors/webcursor.cc ('k') | content/common/gamepad_param_traits.cc » ('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) 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool FontConfigIPC::matchFamilyName(const char familyName[], 83 bool FontConfigIPC::matchFamilyName(const char familyName[],
84 SkTypeface::Style requestedStyle, 84 SkTypeface::Style requestedStyle,
85 FontIdentity* outFontIdentity, 85 FontIdentity* outFontIdentity,
86 SkString* outFamilyName, 86 SkString* outFamilyName,
87 SkTypeface::Style* outStyle) { 87 SkTypeface::Style* outStyle) {
88 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::matchFamilyName"); 88 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::matchFamilyName");
89 size_t familyNameLen = familyName ? strlen(familyName) : 0; 89 size_t familyNameLen = familyName ? strlen(familyName) : 0;
90 if (familyNameLen > kMaxFontFamilyLength) 90 if (familyNameLen > kMaxFontFamilyLength)
91 return false; 91 return false;
92 92
93 Pickle request; 93 base::Pickle request;
94 request.WriteInt(METHOD_MATCH); 94 request.WriteInt(METHOD_MATCH);
95 request.WriteData(familyName, familyNameLen); 95 request.WriteData(familyName, familyNameLen);
96 request.WriteUInt32(requestedStyle); 96 request.WriteUInt32(requestedStyle);
97 97
98 uint8_t reply_buf[2048]; 98 uint8_t reply_buf[2048];
99 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, 99 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
100 sizeof(reply_buf), NULL, 100 sizeof(reply_buf), NULL,
101 request); 101 request);
102 if (r == -1) 102 if (r == -1)
103 return false; 103 return false;
104 104
105 Pickle reply(reinterpret_cast<char*>(reply_buf), r); 105 base::Pickle reply(reinterpret_cast<char*>(reply_buf), r);
106 PickleIterator iter(reply); 106 base::PickleIterator iter(reply);
107 bool result; 107 bool result;
108 if (!iter.ReadBool(&result)) 108 if (!iter.ReadBool(&result))
109 return false; 109 return false;
110 if (!result) 110 if (!result)
111 return false; 111 return false;
112 112
113 SkString reply_family; 113 SkString reply_family;
114 FontIdentity reply_identity; 114 FontIdentity reply_identity;
115 uint32_t reply_style; 115 uint32_t reply_style;
116 if (!skia::ReadSkString(&iter, &reply_family) || 116 if (!skia::ReadSkString(&iter, &reply_family) ||
(...skipping 15 matching lines...) Expand all
132 SkStreamAsset* FontConfigIPC::openStream(const FontIdentity& identity) { 132 SkStreamAsset* FontConfigIPC::openStream(const FontIdentity& identity) {
133 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::openStream"); 133 TRACE_EVENT0("sandbox_ipc", "FontConfigIPC::openStream");
134 134
135 { 135 {
136 base::AutoLock lock(lock_); 136 base::AutoLock lock(lock_);
137 auto mapped_font_files_it = mapped_font_files_.find(identity.fID); 137 auto mapped_font_files_it = mapped_font_files_.find(identity.fID);
138 if (mapped_font_files_it != mapped_font_files_.end()) 138 if (mapped_font_files_it != mapped_font_files_.end())
139 return mapped_font_files_it->second->CreateMemoryStream(); 139 return mapped_font_files_it->second->CreateMemoryStream();
140 } 140 }
141 141
142 Pickle request; 142 base::Pickle request;
143 request.WriteInt(METHOD_OPEN); 143 request.WriteInt(METHOD_OPEN);
144 request.WriteUInt32(identity.fID); 144 request.WriteUInt32(identity.fID);
145 145
146 int result_fd = -1; 146 int result_fd = -1;
147 uint8_t reply_buf[256]; 147 uint8_t reply_buf[256];
148 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf, 148 const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
149 sizeof(reply_buf), 149 sizeof(reply_buf),
150 &result_fd, request); 150 &result_fd, request);
151 151
152 if (r == -1) 152 if (r == -1)
153 return NULL; 153 return NULL;
154 154
155 Pickle reply(reinterpret_cast<char*>(reply_buf), r); 155 base::Pickle reply(reinterpret_cast<char*>(reply_buf), r);
156 bool result; 156 bool result;
157 PickleIterator iter(reply); 157 base::PickleIterator iter(reply);
158 if (!iter.ReadBool(&result) || !result) { 158 if (!iter.ReadBool(&result) || !result) {
159 if (result_fd) 159 if (result_fd)
160 CloseFD(result_fd); 160 CloseFD(result_fd);
161 return NULL; 161 return NULL;
162 } 162 }
163 163
164 scoped_refptr<MappedFontFile> mapped_font_file = 164 scoped_refptr<MappedFontFile> mapped_font_file =
165 new MappedFontFile(identity.fID); 165 new MappedFontFile(identity.fID);
166 if (!mapped_font_file->Initialize(result_fd)) 166 if (!mapped_font_file->Initialize(result_fd))
167 return nullptr; 167 return nullptr;
168 168
169 { 169 {
170 base::AutoLock lock(lock_); 170 base::AutoLock lock(lock_);
171 auto mapped_font_files_it = 171 auto mapped_font_files_it =
172 mapped_font_files_.insert(std::make_pair(mapped_font_file->font_id(), 172 mapped_font_files_.insert(std::make_pair(mapped_font_file->font_id(),
173 mapped_font_file.get())).first; 173 mapped_font_file.get())).first;
174 return mapped_font_files_it->second->CreateMemoryStream(); 174 return mapped_font_files_it->second->CreateMemoryStream();
175 } 175 }
176 } 176 }
177 177
178 void FontConfigIPC::RemoveMappedFontFile(MappedFontFile* mapped_font_file) { 178 void FontConfigIPC::RemoveMappedFontFile(MappedFontFile* mapped_font_file) {
179 base::AutoLock lock(lock_); 179 base::AutoLock lock(lock_);
180 mapped_font_files_.erase(mapped_font_file->font_id()); 180 mapped_font_files_.erase(mapped_font_file->font_id());
181 } 181 }
182 182
183 } // namespace content 183 } // namespace content
184 184
OLDNEW
« no previous file with comments | « content/common/cursors/webcursor.cc ('k') | content/common/gamepad_param_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698