OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/renderer_host/sandbox_ipc_linux.h" | 5 #include "content/browser/renderer_host/sandbox_ipc_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { | 160 } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { |
161 HandleGetStyleForStrike(fd, iter, fds); | 161 HandleGetStyleForStrike(fd, iter, fds); |
162 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { | 162 } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { |
163 HandleMakeSharedMemorySegment(fd, iter, fds); | 163 HandleMakeSharedMemorySegment(fd, iter, fds); |
164 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { | 164 } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { |
165 HandleMatchWithFallback(fd, iter, fds); | 165 HandleMatchWithFallback(fd, iter, fds); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 int SandboxIPCHandler::FindOrAddPath(const SkString& path) { | 169 int SandboxIPCHandler::FindOrAddPath(const SkString& path) { |
170 int count = paths_.count(); | 170 int count = paths_.size(); |
171 for (int i = 0; i < count; ++i) { | 171 for (int i = 0; i < count; ++i) { |
172 if (path == *paths_[i]) | 172 if (path == paths_[i]) |
173 return i; | 173 return i; |
174 } | 174 } |
175 *paths_.append() = new SkString(path); | 175 paths_.emplace_back(path); |
176 return count; | 176 return count; |
177 } | 177 } |
178 | 178 |
179 void SandboxIPCHandler::HandleFontMatchRequest( | 179 void SandboxIPCHandler::HandleFontMatchRequest( |
180 int fd, | 180 int fd, |
181 base::PickleIterator iter, | 181 base::PickleIterator iter, |
182 const std::vector<base::ScopedFD>& fds) { | 182 const std::vector<base::ScopedFD>& fds) { |
183 uint32_t requested_style; | 183 uint32_t requested_style; |
184 std::string family; | 184 std::string family; |
185 if (!iter.ReadString(&family) || !iter.ReadUInt32(&requested_style)) | 185 if (!iter.ReadString(&family) || !iter.ReadUInt32(&requested_style)) |
(...skipping 28 matching lines...) Expand all Loading... |
214 SendRendererReply(fds, reply, -1); | 214 SendRendererReply(fds, reply, -1); |
215 } | 215 } |
216 | 216 |
217 void SandboxIPCHandler::HandleFontOpenRequest( | 217 void SandboxIPCHandler::HandleFontOpenRequest( |
218 int fd, | 218 int fd, |
219 base::PickleIterator iter, | 219 base::PickleIterator iter, |
220 const std::vector<base::ScopedFD>& fds) { | 220 const std::vector<base::ScopedFD>& fds) { |
221 uint32_t index; | 221 uint32_t index; |
222 if (!iter.ReadUInt32(&index)) | 222 if (!iter.ReadUInt32(&index)) |
223 return; | 223 return; |
224 if (index >= static_cast<uint32_t>(paths_.count())) | 224 if (index >= static_cast<uint32_t>(paths_.size())) |
225 return; | 225 return; |
226 const int result_fd = open(paths_[index]->c_str(), O_RDONLY); | 226 const int result_fd = open(paths_[index].c_str(), O_RDONLY); |
227 | 227 |
228 base::Pickle reply; | 228 base::Pickle reply; |
229 if (result_fd == -1) { | 229 if (result_fd == -1) { |
230 reply.WriteBool(false); | 230 reply.WriteBool(false); |
231 } else { | 231 } else { |
232 reply.WriteBool(true); | 232 reply.WriteBool(true); |
233 } | 233 } |
234 | 234 |
235 // The receiver will have its own access to the file, so we will close it | 235 // The receiver will have its own access to the file, so we will close it |
236 // after this send. | 236 // after this send. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 cmsg->cmsg_len = CMSG_LEN(sizeof(int)); | 427 cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
428 memcpy(CMSG_DATA(cmsg), &reply_fd, sizeof(reply_fd)); | 428 memcpy(CMSG_DATA(cmsg), &reply_fd, sizeof(reply_fd)); |
429 msg.msg_controllen = cmsg->cmsg_len; | 429 msg.msg_controllen = cmsg->cmsg_len; |
430 } | 430 } |
431 | 431 |
432 if (HANDLE_EINTR(sendmsg(fds[0].get(), &msg, MSG_DONTWAIT)) < 0) | 432 if (HANDLE_EINTR(sendmsg(fds[0].get(), &msg, MSG_DONTWAIT)) < 0) |
433 PLOG(ERROR) << "sendmsg"; | 433 PLOG(ERROR) << "sendmsg"; |
434 } | 434 } |
435 | 435 |
436 SandboxIPCHandler::~SandboxIPCHandler() { | 436 SandboxIPCHandler::~SandboxIPCHandler() { |
437 paths_.deleteAll(); | |
438 if (blink_platform_impl_) | 437 if (blink_platform_impl_) |
439 blink::shutdownWithoutV8(); | 438 blink::shutdownWithoutV8(); |
440 | 439 |
441 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) | 440 if (IGNORE_EINTR(close(lifeline_fd_)) < 0) |
442 PLOG(ERROR) << "close"; | 441 PLOG(ERROR) << "close"; |
443 if (IGNORE_EINTR(close(browser_socket_)) < 0) | 442 if (IGNORE_EINTR(close(browser_socket_)) < 0) |
444 PLOG(ERROR) << "close"; | 443 PLOG(ERROR) << "close"; |
445 } | 444 } |
446 | 445 |
447 void SandboxIPCHandler::EnsureWebKitInitialized() { | 446 void SandboxIPCHandler::EnsureWebKitInitialized() { |
448 if (blink_platform_impl_) | 447 if (blink_platform_impl_) |
449 return; | 448 return; |
450 blink_platform_impl_.reset(new BlinkPlatformImpl); | 449 blink_platform_impl_.reset(new BlinkPlatformImpl); |
451 blink::initializeWithoutV8(blink_platform_impl_.get()); | 450 blink::initializeWithoutV8(blink_platform_impl_.get()); |
452 } | 451 } |
453 | 452 |
454 } // namespace content | 453 } // namespace content |
OLD | NEW |