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/zygote/zygote_linux.h" | 5 #include "content/zygote/zygote_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // Kill the child process in case it's not already dead, so we can safely | 85 // Kill the child process in case it's not already dead, so we can safely |
86 // perform a blocking wait. | 86 // perform a blocking wait. |
87 PCHECK(0 == kill(pid, SIGKILL)); | 87 PCHECK(0 == kill(pid, SIGKILL)); |
88 PCHECK(pid == HANDLE_EINTR(waitpid(pid, NULL, 0))); | 88 PCHECK(pid == HANDLE_EINTR(waitpid(pid, NULL, 0))); |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 Zygote::Zygote(int sandbox_flags, | 93 Zygote::Zygote(int sandbox_flags, |
94 ScopedVector<ZygoteForkDelegate> helpers, | 94 std::vector<std::unique_ptr<ZygoteForkDelegate>> helpers, |
95 const std::vector<base::ProcessHandle>& extra_children, | 95 const std::vector<base::ProcessHandle>& extra_children, |
96 const std::vector<int>& extra_fds) | 96 const std::vector<int>& extra_fds) |
97 : sandbox_flags_(sandbox_flags), | 97 : sandbox_flags_(sandbox_flags), |
98 helpers_(std::move(helpers)), | 98 helpers_(std::move(helpers)), |
99 initial_uma_index_(0), | 99 initial_uma_index_(0), |
100 extra_children_(extra_children), | 100 extra_children_(extra_children), |
101 extra_fds_(extra_fds), | 101 extra_fds_(extra_fds), |
102 to_reap_() {} | 102 to_reap_() {} |
103 | 103 |
104 Zygote::~Zygote() { | 104 Zygote::~Zygote() { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 411 } |
412 | 412 |
413 int Zygote::ForkWithRealPid(const std::string& process_type, | 413 int Zygote::ForkWithRealPid(const std::string& process_type, |
414 const base::GlobalDescriptors::Mapping& fd_mapping, | 414 const base::GlobalDescriptors::Mapping& fd_mapping, |
415 const std::string& channel_id, | 415 const std::string& channel_id, |
416 base::ScopedFD pid_oracle, | 416 base::ScopedFD pid_oracle, |
417 std::string* uma_name, | 417 std::string* uma_name, |
418 int* uma_sample, | 418 int* uma_sample, |
419 int* uma_boundary_value) { | 419 int* uma_boundary_value) { |
420 ZygoteForkDelegate* helper = NULL; | 420 ZygoteForkDelegate* helper = NULL; |
421 for (ScopedVector<ZygoteForkDelegate>::iterator i = helpers_.begin(); | 421 for (auto i = helpers_.begin(); i != helpers_.end(); ++i) { |
422 i != helpers_.end(); | |
423 ++i) { | |
424 if ((*i)->CanHelp(process_type, uma_name, uma_sample, uma_boundary_value)) { | 422 if ((*i)->CanHelp(process_type, uma_name, uma_sample, uma_boundary_value)) { |
425 helper = *i; | 423 helper = i->get(); |
426 break; | 424 break; |
427 } | 425 } |
428 } | 426 } |
429 | 427 |
430 base::ScopedFD read_pipe, write_pipe; | 428 base::ScopedFD read_pipe, write_pipe; |
431 base::ProcessId pid = 0; | 429 base::ProcessId pid = 0; |
432 if (helper) { | 430 if (helper) { |
433 int mojo_channel_fd = LookUpFd(fd_mapping, kMojoIPCChannel); | 431 int mojo_channel_fd = LookUpFd(fd_mapping, kMojoIPCChannel); |
434 if (mojo_channel_fd < 0) { | 432 if (mojo_channel_fd < 0) { |
435 DLOG(ERROR) << "Failed to find kMojoIPCChannel in FD mapping"; | 433 DLOG(ERROR) << "Failed to find kMojoIPCChannel in FD mapping"; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { | 663 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { |
666 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != | 664 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
667 sizeof(sandbox_flags_)) { | 665 sizeof(sandbox_flags_)) { |
668 PLOG(ERROR) << "write"; | 666 PLOG(ERROR) << "write"; |
669 } | 667 } |
670 | 668 |
671 return false; | 669 return false; |
672 } | 670 } |
673 | 671 |
674 } // namespace content | 672 } // namespace content |
OLD | NEW |