| 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/browser/zygote_host_impl_linux.h" | 5 #include "content/browser/zygote_host_impl_linux.h" |
| 6 | 6 |
| 7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 if (!UnixDomainSocket::SendMsg(control_fd_, pickle.data(), pickle.size(), | 271 if (!UnixDomainSocket::SendMsg(control_fd_, pickle.data(), pickle.size(), |
| 272 fds)) | 272 fds)) |
| 273 return base::kNullProcessHandle; | 273 return base::kNullProcessHandle; |
| 274 | 274 |
| 275 // Read the reply, which pickles the PID and an optional UMA enumeration. | 275 // Read the reply, which pickles the PID and an optional UMA enumeration. |
| 276 static const unsigned kMaxReplyLength = 2048; | 276 static const unsigned kMaxReplyLength = 2048; |
| 277 char buf[kMaxReplyLength]; | 277 char buf[kMaxReplyLength]; |
| 278 const ssize_t len = ReadReply(buf, sizeof(buf)); | 278 const ssize_t len = ReadReply(buf, sizeof(buf)); |
| 279 | 279 |
| 280 Pickle reply_pickle(buf, len); | 280 Pickle reply_pickle(buf, len); |
| 281 void* iter = NULL; | 281 PickleIterator iter(reply_pickle); |
| 282 if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) | 282 if (len <= 0 || !reply_pickle.ReadInt(&iter, &pid)) |
| 283 return base::kNullProcessHandle; | 283 return base::kNullProcessHandle; |
| 284 | 284 |
| 285 // If there is a nonempty UMA name string, then there is a UMA | 285 // If there is a nonempty UMA name string, then there is a UMA |
| 286 // enumeration to record. | 286 // enumeration to record. |
| 287 std::string uma_name; | 287 std::string uma_name; |
| 288 int uma_sample; | 288 int uma_sample; |
| 289 int uma_boundary_value; | 289 int uma_boundary_value; |
| 290 if (reply_pickle.ReadString(&iter, &uma_name) && | 290 if (reply_pickle.ReadString(&iter, &uma_name) && |
| 291 !uma_name.empty() && | 291 !uma_name.empty() && |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 if (len == -1) { | 430 if (len == -1) { |
| 431 LOG(WARNING) << "Error reading message from zygote: " << errno; | 431 LOG(WARNING) << "Error reading message from zygote: " << errno; |
| 432 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 432 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 433 } else if (len == 0) { | 433 } else if (len == 0) { |
| 434 LOG(WARNING) << "Socket closed prematurely."; | 434 LOG(WARNING) << "Socket closed prematurely."; |
| 435 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 435 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 436 } | 436 } |
| 437 | 437 |
| 438 Pickle read_pickle(buf, len); | 438 Pickle read_pickle(buf, len); |
| 439 int status, tmp_exit_code; | 439 int status, tmp_exit_code; |
| 440 void* iter = NULL; | 440 PickleIterator iter(read_pickle); |
| 441 if (!read_pickle.ReadInt(&iter, &status) || | 441 if (!read_pickle.ReadInt(&iter, &status) || |
| 442 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { | 442 !read_pickle.ReadInt(&iter, &tmp_exit_code)) { |
| 443 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; | 443 LOG(WARNING) << "Error parsing GetTerminationStatus response from zygote."; |
| 444 return base::TERMINATION_STATUS_NORMAL_TERMINATION; | 444 return base::TERMINATION_STATUS_NORMAL_TERMINATION; |
| 445 } | 445 } |
| 446 | 446 |
| 447 if (exit_code) | 447 if (exit_code) |
| 448 *exit_code = tmp_exit_code; | 448 *exit_code = tmp_exit_code; |
| 449 | 449 |
| 450 return static_cast<base::TerminationStatus>(status); | 450 return static_cast<base::TerminationStatus>(status); |
| 451 } | 451 } |
| 452 | 452 |
| 453 pid_t ZygoteHostImpl::GetPid() const { | 453 pid_t ZygoteHostImpl::GetPid() const { |
| 454 return pid_; | 454 return pid_; |
| 455 } | 455 } |
| 456 | 456 |
| 457 pid_t ZygoteHostImpl::GetSandboxHelperPid() const { | 457 pid_t ZygoteHostImpl::GetSandboxHelperPid() const { |
| 458 return RenderSandboxHostLinux::GetInstance()->pid(); | 458 return RenderSandboxHostLinux::GetInstance()->pid(); |
| 459 } | 459 } |
| 460 | 460 |
| 461 int ZygoteHostImpl::GetSandboxStatus() const { | 461 int ZygoteHostImpl::GetSandboxStatus() const { |
| 462 if (have_read_sandbox_status_word_) | 462 if (have_read_sandbox_status_word_) |
| 463 return sandbox_status_; | 463 return sandbox_status_; |
| 464 return 0; | 464 return 0; |
| 465 } | 465 } |
| OLD | NEW |