| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/zygote_host/zygote_communication_linux.h" | 5 #include "content/browser/zygote_host/zygote_communication_linux.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 child_tracking_lock_(), | 34 child_tracking_lock_(), |
| 35 sandbox_status_(0), | 35 sandbox_status_(0), |
| 36 have_read_sandbox_status_word_(false), | 36 have_read_sandbox_status_word_(false), |
| 37 init_(false) {} | 37 init_(false) {} |
| 38 | 38 |
| 39 ZygoteCommunication::~ZygoteCommunication() {} | 39 ZygoteCommunication::~ZygoteCommunication() {} |
| 40 | 40 |
| 41 bool ZygoteCommunication::SendMessage(const base::Pickle& data, | 41 bool ZygoteCommunication::SendMessage(const base::Pickle& data, |
| 42 const std::vector<int>* fds) { | 42 const std::vector<int>* fds) { |
| 43 DCHECK(control_fd_.is_valid()); | 43 DCHECK(control_fd_.is_valid()); |
| 44 CHECK(data.size() <= kZygoteMaxMessageLength) | 44 // Trying to send too-large message to zygote. |
| 45 << "Trying to send too-large message to zygote (sending " << data.size() | 45 CHECK(data.size() <= kZygoteMaxMessageLength); |
| 46 << " bytes, max is " << kZygoteMaxMessageLength << ")"; | 46 // Trying to send message with too many file descriptors to zygote. |
| 47 CHECK(!fds || fds->size() <= base::UnixDomainSocket::kMaxFileDescriptors) | 47 CHECK(!fds || fds->size() <= base::UnixDomainSocket::kMaxFileDescriptors); |
| 48 << "Trying to send message with too many file descriptors to zygote " | |
| 49 << "(sending " << fds->size() << ", max is " | |
| 50 << base::UnixDomainSocket::kMaxFileDescriptors << ")"; | |
| 51 | 48 |
| 52 return base::UnixDomainSocket::SendMsg(control_fd_.get(), data.data(), | 49 return base::UnixDomainSocket::SendMsg(control_fd_.get(), data.data(), |
| 53 data.size(), | 50 data.size(), |
| 54 fds ? *fds : std::vector<int>()); | 51 fds ? *fds : std::vector<int>()); |
| 55 } | 52 } |
| 56 | 53 |
| 57 ssize_t ZygoteCommunication::ReadSandboxStatus() { | 54 ssize_t ZygoteCommunication::ReadSandboxStatus() { |
| 58 DCHECK(control_fd_.is_valid()); | 55 DCHECK(control_fd_.is_valid()); |
| 59 // At startup we send a kZygoteCommandGetSandboxStatus request to the zygote, | 56 // At startup we send a kZygoteCommandGetSandboxStatus request to the zygote, |
| 60 // but don't wait for the reply. Thus, the first time that we read from the | 57 // but don't wait for the reply. Thus, the first time that we read from the |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 325 } |
| 329 if (ReadSandboxStatus() == -1) { | 326 if (ReadSandboxStatus() == -1) { |
| 330 return 0; | 327 return 0; |
| 331 } | 328 } |
| 332 have_read_sandbox_status_word_ = true; | 329 have_read_sandbox_status_word_ = true; |
| 333 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); | 330 UMA_HISTOGRAM_SPARSE_SLOWLY("Linux.SandboxStatus", sandbox_status_); |
| 334 return sandbox_status_; | 331 return sandbox_status_; |
| 335 } | 332 } |
| 336 | 333 |
| 337 } // namespace content | 334 } // namespace content |
| OLD | NEW |