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

Unified Diff: content/zygote/zygote_linux.cc

Issue 1508213002: Replace ScopedVector<ScopedFD> with std::vector<ScopedFD> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: content/zygote/zygote_linux.cc
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc
index d582eb1334d506113f7ff4b44c346ed6bf9b6174..2125d81dfbb770d7e3c79fef40ae615a00d1f4ed 100644
--- a/content/zygote/zygote_linux.cc
+++ b/content/zygote/zygote_linux.cc
@@ -20,7 +20,6 @@
#include "base/linux_util.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/memory/scoped_vector.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/global_descriptors.h"
@@ -229,7 +228,7 @@ bool Zygote::UsingNSSandbox() const {
}
bool Zygote::HandleRequestFromBrowser(int fd) {
- ScopedVector<base::ScopedFD> fds;
+ std::vector<base::ScopedFD> fds;
char buf[kZygoteMaxMessageLength];
const ssize_t len = base::UnixDomainSocket::RecvMsg(
fd, buf, sizeof(buf), &fds);
@@ -237,21 +236,18 @@ bool Zygote::HandleRequestFromBrowser(int fd) {
if (len == 0 || (len == -1 && errno == ECONNRESET)) {
// EOF from the browser. We should die.
// TODO(earthdok): call __sanititizer_cov_dump() here to obtain code
- // coverage for the Zygote. Currently it's not possible because of
+ // coverage for the Zygote. Currently it's not possible because of
// confusion over who is responsible for closing the file descriptor.
- for (std::vector<int>::iterator it = extra_fds_.begin();
- it < extra_fds_.end(); ++it) {
- PCHECK(0 == IGNORE_EINTR(close(*it)));
+ for (int fd : extra_fds_) {
+ PCHECK(0 == IGNORE_EINTR(close(fd)));
}
#if !defined(SANITIZER_COVERAGE)
// TODO(earthdok): add watchdog thread before using this in builds not
// using sanitizer coverage.
CHECK(extra_children_.empty());
#endif
- for (std::vector<base::ProcessHandle>::iterator it =
- extra_children_.begin();
- it < extra_children_.end(); ++it) {
- PCHECK(*it == HANDLE_EINTR(waitpid(*it, NULL, 0)));
+ for (base::ProcessHandle pid : extra_children_) {
+ PCHECK(pid == HANDLE_EINTR(waitpid(pid, NULL, 0)));
}
_exit(0);
return false;
@@ -270,7 +266,7 @@ bool Zygote::HandleRequestFromBrowser(int fd) {
switch (kind) {
case kZygoteCommandFork:
// This function call can return multiple times, once per fork().
- return HandleForkRequest(fd, iter, fds.Pass());
+ return HandleForkRequest(fd, iter, std::move(fds));
case kZygoteCommandReap:
if (!fds.empty())
@@ -505,7 +501,7 @@ int Zygote::ForkWithRealPid(const std::string& process_type,
// be invalid (see below).
base::ProcessId real_pid;
{
- ScopedVector<base::ScopedFD> recv_fds;
+ std::vector<base::ScopedFD> recv_fds;
char buf[kZygoteMaxMessageLength];
const ssize_t len = base::UnixDomainSocket::RecvMsg(
kZygoteSocketPairFd, buf, sizeof(buf), &recv_fds);
@@ -555,7 +551,7 @@ int Zygote::ForkWithRealPid(const std::string& process_type,
}
base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
- ScopedVector<base::ScopedFD> fds,
+ std::vector<base::ScopedFD> fds,
std::string* uma_name,
int* uma_sample,
int* uma_boundary_value) {
@@ -590,14 +586,14 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
// First FD is the PID oracle socket.
if (fds.size() < 1)
return -1;
- base::ScopedFD pid_oracle(std::move(*fds[0]));
+ base::ScopedFD pid_oracle(std::move(fds[0]));
// Remaining FDs are for the global descriptor mapping.
for (int i = 1; i < numfds; ++i) {
base::GlobalDescriptors::Key key;
if (!iter.ReadUInt32(&key))
return -1;
- mapping.push_back(base::GlobalDescriptors::Descriptor(key, fds[i]->get()));
+ mapping.push_back(base::GlobalDescriptors::Descriptor(key, fds[i].get()));
}
mapping.push_back(base::GlobalDescriptors::Descriptor(
@@ -614,9 +610,8 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
PCHECK(0 == IGNORE_EINTR(close(kZygoteSocketPairFd)));
// Pass ownership of file descriptors from fds to GlobalDescriptors.
- for (ScopedVector<base::ScopedFD>::iterator i = fds.begin(); i != fds.end();
- ++i)
- ignore_result((*i)->release());
+ for (base::ScopedFD& fd : fds)
+ ignore_result(fd.release());
base::GlobalDescriptors::GetInstance()->Reset(mapping);
// Reset the process-wide command line to our new command line.
@@ -637,12 +632,12 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
bool Zygote::HandleForkRequest(int fd,
base::PickleIterator iter,
- ScopedVector<base::ScopedFD> fds) {
+ std::vector<base::ScopedFD> fds) {
std::string uma_name;
int uma_sample;
int uma_boundary_value;
base::ProcessId child_pid = ReadArgsAndFork(
- iter, fds.Pass(), &uma_name, &uma_sample, &uma_boundary_value);
+ iter, std::move(fds), &uma_name, &uma_sample, &uma_boundary_value);
if (child_pid == 0)
return true;
// If there's no UMA report for this particular fork, then check if any

Powered by Google App Engine
This is Rietveld 408576698