diff options
-rw-r--r-- | base/posix/unix_domain_socket_linux.cc | 13 | ||||
-rw-r--r-- | base/posix/unix_domain_socket_linux.h | 7 | ||||
-rw-r--r-- | base/posix/unix_domain_socket_linux_unittest.cc | 9 | ||||
-rw-r--r-- | components/nacl/loader/nacl_helper_linux.cc | 41 | ||||
-rw-r--r-- | components/nacl/zygote/nacl_fork_delegate_linux.cc | 2 | ||||
-rw-r--r-- | content/browser/file_descriptor_info_impl.cc | 16 | ||||
-rw-r--r-- | content/browser/file_descriptor_info_impl.h | 5 | ||||
-rw-r--r-- | content/browser/renderer_host/sandbox_ipc_linux.cc | 35 | ||||
-rw-r--r-- | content/browser/renderer_host/sandbox_ipc_linux.h | 18 | ||||
-rw-r--r-- | content/browser/zygote_host/zygote_host_impl_linux.cc | 5 | ||||
-rw-r--r-- | content/zygote/zygote_linux.cc | 38 | ||||
-rw-r--r-- | content/zygote/zygote_linux.h | 5 | ||||
-rw-r--r-- | extensions/shell/app/shell_main_delegate.h | 1 | ||||
-rw-r--r-- | sandbox/linux/integration_tests/namespace_unix_domain_socket_unittest.cc | 6 | ||||
-rw-r--r-- | sandbox/linux/syscall_broker/broker_host.cc | 7 |
15 files changed, 95 insertions, 113 deletions
diff --git a/base/posix/unix_domain_socket_linux.cc b/base/posix/unix_domain_socket_linux.cc index 62c930f..88a90f6 100644 --- a/base/posix/unix_domain_socket_linux.cc +++ b/base/posix/unix_domain_socket_linux.cc @@ -12,7 +12,6 @@ #include "base/files/scoped_file.h" #include "base/logging.h" -#include "base/memory/scoped_vector.h" #include "base/pickle.h" #include "base/posix/eintr_wrapper.h" #include "base/stl_util.h" @@ -86,7 +85,7 @@ bool UnixDomainSocket::SendMsg(int fd, ssize_t UnixDomainSocket::RecvMsg(int fd, void* buf, size_t length, - ScopedVector<ScopedFD>* fds) { + std::vector<ScopedFD>* fds) { return UnixDomainSocket::RecvMsgWithPid(fd, buf, length, fds, NULL); } @@ -94,7 +93,7 @@ ssize_t UnixDomainSocket::RecvMsg(int fd, ssize_t UnixDomainSocket::RecvMsgWithPid(int fd, void* buf, size_t length, - ScopedVector<ScopedFD>* fds, + std::vector<ScopedFD>* fds, ProcessId* pid) { return UnixDomainSocket::RecvMsgWithFlags(fd, buf, length, 0, fds, pid); } @@ -104,7 +103,7 @@ ssize_t UnixDomainSocket::RecvMsgWithFlags(int fd, void* buf, size_t length, int flags, - ScopedVector<ScopedFD>* fds, + std::vector<ScopedFD>* fds, ProcessId* out_pid) { fds->clear(); @@ -165,7 +164,7 @@ ssize_t UnixDomainSocket::RecvMsgWithFlags(int fd, if (wire_fds) { for (unsigned i = 0; i < wire_fds_len; ++i) - fds->push_back(new ScopedFD(wire_fds[i])); + fds->push_back(ScopedFD(wire_fds[i])); // TODO(mdempsky): emplace_back } if (out_pid) { @@ -219,7 +218,7 @@ ssize_t UnixDomainSocket::SendRecvMsgWithFlags(int fd, // return EOF instead of hanging. send_sock.reset(); - ScopedVector<ScopedFD> recv_fds; + std::vector<ScopedFD> recv_fds; // When porting to OSX keep in mind it doesn't support MSG_NOSIGNAL, so the // sender might get a SIGPIPE. const ssize_t reply_len = RecvMsgWithFlags( @@ -236,7 +235,7 @@ ssize_t UnixDomainSocket::SendRecvMsgWithFlags(int fd, } if (result_fd) - *result_fd = recv_fds.empty() ? -1 : recv_fds[0]->release(); + *result_fd = recv_fds.empty() ? -1 : recv_fds[0].release(); return reply_len; } diff --git a/base/posix/unix_domain_socket_linux.h b/base/posix/unix_domain_socket_linux.h index 94da4b4..98c9d61 100644 --- a/base/posix/unix_domain_socket_linux.h +++ b/base/posix/unix_domain_socket_linux.h @@ -11,7 +11,6 @@ #include "base/base_export.h" #include "base/files/scoped_file.h" -#include "base/memory/scoped_vector.h" #include "base/process/process_handle.h" namespace base { @@ -42,7 +41,7 @@ class BASE_EXPORT UnixDomainSocket { static ssize_t RecvMsg(int fd, void* msg, size_t length, - ScopedVector<ScopedFD>* fds); + std::vector<ScopedFD>* fds); // Same as RecvMsg above, but also returns the sender's process ID (as seen // from the caller's namespace). However, before using this function to @@ -51,7 +50,7 @@ class BASE_EXPORT UnixDomainSocket { static ssize_t RecvMsgWithPid(int fd, void* msg, size_t length, - ScopedVector<ScopedFD>* fds, + std::vector<ScopedFD>* fds, ProcessId* pid); #if !defined(OS_NACL_NONSFI) @@ -94,7 +93,7 @@ class BASE_EXPORT UnixDomainSocket { void* msg, size_t length, int flags, - ScopedVector<ScopedFD>* fds, + std::vector<ScopedFD>* fds, ProcessId* pid); }; diff --git a/base/posix/unix_domain_socket_linux_unittest.cc b/base/posix/unix_domain_socket_linux_unittest.cc index 175ec52..c683e3a 100644 --- a/base/posix/unix_domain_socket_linux_unittest.cc +++ b/base/posix/unix_domain_socket_linux_unittest.cc @@ -11,7 +11,6 @@ #include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/location.h" -#include "base/memory/scoped_vector.h" #include "base/pickle.h" #include "base/posix/unix_domain_socket_linux.h" #include "base/single_thread_task_runner.h" @@ -40,7 +39,7 @@ TEST(UnixDomainSocketTest, SendRecvMsgAbortOnReplyFDClose) { static_cast<uint8_t*>(NULL), 0U, static_cast<int*>(NULL), request)); // Receive the message. - ScopedVector<ScopedFD> message_fds; + std::vector<ScopedFD> message_fds; uint8_t buffer[16]; ASSERT_EQ(static_cast<int>(request.size()), UnixDomainSocket::RecvMsg(fds[0], buffer, sizeof(buffer), @@ -95,7 +94,7 @@ TEST(UnixDomainSocketTest, RecvPid) { // sizeof(kHello) bytes and it wasn't just truncated to fit the buffer. char buf[sizeof(kHello) + 1]; ProcessId sender_pid; - ScopedVector<ScopedFD> fd_vec; + std::vector<ScopedFD> fd_vec; const ssize_t nread = UnixDomainSocket::RecvMsgWithPid( recv_sock.get(), buf, sizeof(buf), &fd_vec, &sender_pid); ASSERT_EQ(sizeof(kHello), static_cast<size_t>(nread)); @@ -124,7 +123,7 @@ TEST(UnixDomainSocketTest, RecvPidWithMaxDescriptors) { // sizeof(kHello) bytes and it wasn't just truncated to fit the buffer. char buf[sizeof(kHello) + 1]; ProcessId sender_pid; - ScopedVector<ScopedFD> recv_fds; + std::vector<ScopedFD> recv_fds; const ssize_t nread = UnixDomainSocket::RecvMsgWithPid( recv_sock.get(), buf, sizeof(buf), &recv_fds, &sender_pid); ASSERT_EQ(sizeof(kHello), static_cast<size_t>(nread)); @@ -148,7 +147,7 @@ TEST(UnixDomianSocketTest, RecvPidDisconnectedSocket) { char ch; ProcessId sender_pid; - ScopedVector<ScopedFD> recv_fds; + std::vector<ScopedFD> recv_fds; const ssize_t nread = UnixDomainSocket::RecvMsgWithPid( recv_sock.get(), &ch, sizeof(ch), &recv_fds, &sender_pid); ASSERT_EQ(0, nread); diff --git a/components/nacl/loader/nacl_helper_linux.cc b/components/nacl/loader/nacl_helper_linux.cc index 010239a..462cca9 100644 --- a/components/nacl/loader/nacl_helper_linux.cc +++ b/components/nacl/loader/nacl_helper_linux.cc @@ -16,6 +16,7 @@ #include <sys/types.h> #include <string> +#include <utility> #include <vector> #include "base/at_exit.h" @@ -23,7 +24,6 @@ #include "base/files/scoped_file.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/posix/eintr_wrapper.h" #include "base/posix/global_descriptors.h" @@ -132,7 +132,7 @@ void BecomeNaClLoader(base::ScopedFD browser_fd, } // Start the NaCl loader in a child created by the NaCl loader Zygote. -void ChildNaClLoaderInit(ScopedVector<base::ScopedFD> child_fds, +void ChildNaClLoaderInit(std::vector<base::ScopedFD> child_fds, const NaClLoaderSystemInfo& system_info, bool uses_nonsfi_mode, nacl::NaClSandbox* nacl_sandbox, @@ -143,25 +143,25 @@ void ChildNaClLoaderInit(ScopedVector<base::ScopedFD> child_fds, // Ping the PID oracle socket. CHECK(content::SendZygoteChildPing( - child_fds[content::ZygoteForkDelegate::kPIDOracleFDIndex]->get())); + child_fds[content::ZygoteForkDelegate::kPIDOracleFDIndex].get())); base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( switches::kProcessChannelID, channel_id); // Save the browser socket and close the rest. base::ScopedFD browser_fd( - child_fds[content::ZygoteForkDelegate::kBrowserFDIndex]->Pass()); + std::move(child_fds[content::ZygoteForkDelegate::kBrowserFDIndex])); child_fds.clear(); - BecomeNaClLoader( - browser_fd.Pass(), system_info, uses_nonsfi_mode, nacl_sandbox); + BecomeNaClLoader(std::move(browser_fd), system_info, uses_nonsfi_mode, + nacl_sandbox); _exit(1); } // Handle a fork request from the Zygote. // Some of this code was lifted from // content/browser/zygote_main_linux.cc:ForkWithRealPid() -bool HandleForkRequest(ScopedVector<base::ScopedFD> child_fds, +bool HandleForkRequest(std::vector<base::ScopedFD> child_fds, const NaClLoaderSystemInfo& system_info, nacl::NaClSandbox* nacl_sandbox, base::PickleIterator* input_iter, @@ -207,11 +207,8 @@ bool HandleForkRequest(ScopedVector<base::ScopedFD> child_fds, // is fine. sandbox::NamespaceSandbox::InstallDefaultTerminationSignalHandlers(); } - ChildNaClLoaderInit(child_fds.Pass(), - system_info, - uses_nonsfi_mode, - nacl_sandbox, - channel_id); + ChildNaClLoaderInit(std::move(child_fds), system_info, uses_nonsfi_mode, + nacl_sandbox, channel_id); NOTREACHED(); } @@ -261,7 +258,7 @@ bool HandleGetTerminationStatusRequest(base::PickleIterator* input_iter, // Reply to the command on |reply_fds|. bool HonorRequestAndReply(int reply_fd, int command_type, - ScopedVector<base::ScopedFD> attached_fds, + std::vector<base::ScopedFD> attached_fds, const NaClLoaderSystemInfo& system_info, nacl::NaClSandbox* nacl_sandbox, base::PickleIterator* input_iter) { @@ -270,11 +267,9 @@ bool HonorRequestAndReply(int reply_fd, // Commands must write anything to send back to |write_pickle|. switch (command_type) { case nacl::kNaClForkRequest: - have_to_reply = HandleForkRequest(attached_fds.Pass(), - system_info, - nacl_sandbox, - input_iter, - &write_pickle); + have_to_reply = + HandleForkRequest(std::move(attached_fds), system_info, nacl_sandbox, + input_iter, &write_pickle); break; case nacl::kNaClGetTerminationStatusRequest: have_to_reply = @@ -300,7 +295,7 @@ bool HonorRequestAndReply(int reply_fd, bool HandleZygoteRequest(int zygote_ipc_fd, const NaClLoaderSystemInfo& system_info, nacl::NaClSandbox* nacl_sandbox) { - ScopedVector<base::ScopedFD> fds; + std::vector<base::ScopedFD> fds; char buf[kNaClMaxIPCMessageLength]; const ssize_t msglen = base::UnixDomainSocket::RecvMsg(zygote_ipc_fd, &buf, sizeof(buf), &fds); @@ -327,12 +322,8 @@ bool HandleZygoteRequest(int zygote_ipc_fd, LOG(ERROR) << "Unable to read command from Zygote"; return false; } - return HonorRequestAndReply(zygote_ipc_fd, - command_type, - fds.Pass(), - system_info, - nacl_sandbox, - &read_iter); + return HonorRequestAndReply(zygote_ipc_fd, command_type, std::move(fds), + system_info, nacl_sandbox, &read_iter); } #if !defined(OS_NACL_NONSFI) diff --git a/components/nacl/zygote/nacl_fork_delegate_linux.cc b/components/nacl/zygote/nacl_fork_delegate_linux.cc index ae62564..e05e2ec 100644 --- a/components/nacl/zygote/nacl_fork_delegate_linux.cc +++ b/components/nacl/zygote/nacl_fork_delegate_linux.cc @@ -113,7 +113,7 @@ bool SendIPCRequestAndReadReply(int ipc_channel, } // Then read the remote reply. - ScopedVector<base::ScopedFD> received_fds; + std::vector<base::ScopedFD> received_fds; const ssize_t msg_len = base::UnixDomainSocket::RecvMsg(ipc_channel, reply_data_buffer, reply_data_buffer_size, &received_fds); diff --git a/content/browser/file_descriptor_info_impl.cc b/content/browser/file_descriptor_info_impl.cc index c6cf831..f071b42 100644 --- a/content/browser/file_descriptor_info_impl.cc +++ b/content/browser/file_descriptor_info_impl.cc @@ -6,6 +6,8 @@ #include <utility> +#include "base/stl_util.h" + namespace content { // static @@ -25,7 +27,7 @@ void FileDescriptorInfoImpl::Share(int id, base::PlatformFile fd) { void FileDescriptorInfoImpl::Transfer(int id, base::ScopedFD fd) { AddToMapping(id, fd.get()); - owned_descriptors_.push_back(new base::ScopedFD(std::move(fd))); + owned_descriptors_.push_back(std::move(fd)); } base::PlatformFile FileDescriptorInfoImpl::GetFDAt(size_t i) const { @@ -50,21 +52,17 @@ bool FileDescriptorInfoImpl::HasID(int id) const { } bool FileDescriptorInfoImpl::OwnsFD(base::PlatformFile file) const { - return owned_descriptors_.end() != - std::find_if( - owned_descriptors_.begin(), owned_descriptors_.end(), - [file](const base::ScopedFD* fd) { return fd->get() == file; }); + return ContainsValue(owned_descriptors_, file); } base::ScopedFD FileDescriptorInfoImpl::ReleaseFD(base::PlatformFile file) { DCHECK(OwnsFD(file)); base::ScopedFD fd; - auto found = std::find_if( - owned_descriptors_.begin(), owned_descriptors_.end(), - [file](const base::ScopedFD* fd) { return fd->get() == file; }); + auto found = + std::find(owned_descriptors_.begin(), owned_descriptors_.end(), file); - (*found)->swap(fd); + std::swap(*found, fd); owned_descriptors_.erase(found); return fd; diff --git a/content/browser/file_descriptor_info_impl.h b/content/browser/file_descriptor_info_impl.h index 40db959..0e25abf 100644 --- a/content/browser/file_descriptor_info_impl.h +++ b/content/browser/file_descriptor_info_impl.h @@ -5,8 +5,9 @@ #ifndef CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ #define CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ +#include <vector> + #include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" #include "content/common/content_export.h" #include "content/public/browser/file_descriptor_info.h" @@ -34,7 +35,7 @@ class FileDescriptorInfoImpl : public FileDescriptorInfo { void AddToMapping(int id, base::PlatformFile fd); bool HasID(int id) const; base::FileHandleMappingVector mapping_; - ScopedVector<base::ScopedFD> owned_descriptors_; + std::vector<base::ScopedFD> owned_descriptors_; }; } diff --git a/content/browser/renderer_host/sandbox_ipc_linux.cc b/content/browser/renderer_host/sandbox_ipc_linux.cc index 966f350..b77ec14 100644 --- a/content/browser/renderer_host/sandbox_ipc_linux.cc +++ b/content/browser/renderer_host/sandbox_ipc_linux.cc @@ -14,7 +14,6 @@ #include "base/files/scoped_file.h" #include "base/linux_util.h" #include "base/macros.h" -#include "base/memory/scoped_vector.h" #include "base/memory/shared_memory.h" #include "base/posix/eintr_wrapper.h" #include "base/posix/unix_domain_socket_linux.h" @@ -123,7 +122,7 @@ void SandboxIPCHandler::Run() { } void SandboxIPCHandler::HandleRequestFromRenderer(int fd) { - ScopedVector<base::ScopedFD> fds; + std::vector<base::ScopedFD> fds; // A FontConfigIPC::METHOD_MATCH message could be kMaxFontFamilyLength // bytes long (this is the largest message type). @@ -149,19 +148,19 @@ void SandboxIPCHandler::HandleRequestFromRenderer(int fd) { return; if (kind == FontConfigIPC::METHOD_MATCH) { - HandleFontMatchRequest(fd, iter, fds.get()); + HandleFontMatchRequest(fd, iter, fds); } else if (kind == FontConfigIPC::METHOD_OPEN) { - HandleFontOpenRequest(fd, iter, fds.get()); + HandleFontOpenRequest(fd, iter, fds); } else if (kind == LinuxSandbox::METHOD_GET_FALLBACK_FONT_FOR_CHAR) { - HandleGetFallbackFontForChar(fd, iter, fds.get()); + HandleGetFallbackFontForChar(fd, iter, fds); } else if (kind == LinuxSandbox::METHOD_LOCALTIME) { - HandleLocaltime(fd, iter, fds.get()); + HandleLocaltime(fd, iter, fds); } else if (kind == LinuxSandbox::METHOD_GET_STYLE_FOR_STRIKE) { - HandleGetStyleForStrike(fd, iter, fds.get()); + HandleGetStyleForStrike(fd, iter, fds); } else if (kind == LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT) { - HandleMakeSharedMemorySegment(fd, iter, fds.get()); + HandleMakeSharedMemorySegment(fd, iter, fds); } else if (kind == LinuxSandbox::METHOD_MATCH_WITH_FALLBACK) { - HandleMatchWithFallback(fd, iter, fds.get()); + HandleMatchWithFallback(fd, iter, fds); } } @@ -178,7 +177,7 @@ int SandboxIPCHandler::FindOrAddPath(const SkString& path) { void SandboxIPCHandler::HandleFontMatchRequest( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { uint32_t requested_style; std::string family; if (!iter.ReadString(&family) || !iter.ReadUInt32(&requested_style)) @@ -216,7 +215,7 @@ void SandboxIPCHandler::HandleFontMatchRequest( void SandboxIPCHandler::HandleFontOpenRequest( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { uint32_t index; if (!iter.ReadUInt32(&index)) return; @@ -244,7 +243,7 @@ void SandboxIPCHandler::HandleFontOpenRequest( void SandboxIPCHandler::HandleGetFallbackFontForChar( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { // The other side of this call is // content/common/child_process_sandbox_support_impl_linux.cc @@ -284,7 +283,7 @@ void SandboxIPCHandler::HandleGetFallbackFontForChar( void SandboxIPCHandler::HandleGetStyleForStrike( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { std::string family; bool bold, italic; uint16 pixel_size; @@ -322,7 +321,7 @@ void SandboxIPCHandler::HandleGetStyleForStrike( void SandboxIPCHandler::HandleLocaltime( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { // The other side of this call is in zygote_main_linux.cc std::string time_string; @@ -352,7 +351,7 @@ void SandboxIPCHandler::HandleLocaltime( void SandboxIPCHandler::HandleMakeSharedMemorySegment( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { base::SharedMemoryCreateOptions options; uint32_t size; if (!iter.ReadUInt32(&size)) @@ -371,7 +370,7 @@ void SandboxIPCHandler::HandleMakeSharedMemorySegment( void SandboxIPCHandler::HandleMatchWithFallback( int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds) { + const std::vector<base::ScopedFD>& fds) { std::string face; bool is_bold, is_italic; uint32 charset, fallback_family; @@ -397,7 +396,7 @@ void SandboxIPCHandler::HandleMatchWithFallback( } void SandboxIPCHandler::SendRendererReply( - const std::vector<base::ScopedFD*>& fds, + const std::vector<base::ScopedFD>& fds, const base::Pickle& reply, int reply_fd) { struct msghdr msg; @@ -428,7 +427,7 @@ void SandboxIPCHandler::SendRendererReply( msg.msg_controllen = cmsg->cmsg_len; } - if (HANDLE_EINTR(sendmsg(fds[0]->get(), &msg, MSG_DONTWAIT)) < 0) + if (HANDLE_EINTR(sendmsg(fds[0].get(), &msg, MSG_DONTWAIT)) < 0) PLOG(ERROR) << "sendmsg"; } diff --git a/content/browser/renderer_host/sandbox_ipc_linux.h b/content/browser/renderer_host/sandbox_ipc_linux.h index 23a65e0..0d647049 100644 --- a/content/browser/renderer_host/sandbox_ipc_linux.h +++ b/content/browser/renderer_host/sandbox_ipc_linux.h @@ -37,33 +37,33 @@ class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate { void HandleFontMatchRequest(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); void HandleFontOpenRequest(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); void HandleGetFallbackFontForChar(int fd, - base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + base::PickleIterator iter, + const std::vector<base::ScopedFD>& fds); void HandleGetStyleForStrike(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); void HandleLocaltime(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); void HandleMakeSharedMemorySegment(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); void HandleMatchWithFallback(int fd, base::PickleIterator iter, - const std::vector<base::ScopedFD*>& fds); + const std::vector<base::ScopedFD>& fds); - void SendRendererReply(const std::vector<base::ScopedFD*>& fds, + void SendRendererReply(const std::vector<base::ScopedFD>& fds, const base::Pickle& reply, int reply_fd); diff --git a/content/browser/zygote_host/zygote_host_impl_linux.cc b/content/browser/zygote_host/zygote_host_impl_linux.cc index a736fb0..3b82e2a 100644 --- a/content/browser/zygote_host/zygote_host_impl_linux.cc +++ b/content/browser/zygote_host/zygote_host_impl_linux.cc @@ -21,7 +21,6 @@ #include "base/logging.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" #include "base/metrics/histogram.h" #include "base/metrics/sparse_histogram.h" #include "base/path_service.h" @@ -63,7 +62,7 @@ bool ReceiveFixedMessage(int fd, size_t expect_len, base::ProcessId* sender_pid) { char buf[expect_len + 1]; - ScopedVector<base::ScopedFD> fds_vec; + std::vector<base::ScopedFD> fds_vec; const ssize_t len = base::UnixDomainSocket::RecvMsgWithPid( fd, buf, sizeof(buf), &fds_vec, sender_pid); @@ -363,7 +362,7 @@ pid_t ZygoteHostImpl::ForkRequest(const std::vector<std::string>& argv, { char buf[sizeof(kZygoteChildPingMessage) + 1]; - ScopedVector<base::ScopedFD> recv_fds; + std::vector<base::ScopedFD> recv_fds; base::ProcessId real_pid; ssize_t n = base::UnixDomainSocket::RecvMsgWithPid( diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc index d582eb1..cb92d71 100644 --- a/content/zygote/zygote_linux.cc +++ b/content/zygote/zygote_linux.cc @@ -13,6 +13,7 @@ #include <sys/socket.h> #include <sys/types.h> #include <sys/wait.h> + #include <utility> #include "base/command_line.h" @@ -20,7 +21,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 +229,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 +237,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 +267,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 +502,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 +552,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 +587,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 +611,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 +633,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); + base::ProcessId child_pid = ReadArgsAndFork(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 diff --git a/content/zygote/zygote_linux.h b/content/zygote/zygote_linux.h index f96b906d..b1eecd6 100644 --- a/content/zygote/zygote_linux.h +++ b/content/zygote/zygote_linux.h @@ -8,6 +8,7 @@ #include <stddef.h> #include <string> +#include <vector> #include "base/containers/small_map.h" #include "base/files/scoped_file.h" @@ -104,7 +105,7 @@ class Zygote { // Returns -1 on error, otherwise returns twice, returning 0 to the child // process and the child process ID to the parent process, like fork(). base::ProcessId ReadArgsAndFork(base::PickleIterator iter, - ScopedVector<base::ScopedFD> fds, + std::vector<base::ScopedFD> fds, std::string* uma_name, int* uma_sample, int* uma_boundary_value); @@ -115,7 +116,7 @@ class Zygote { // child_pid of -1 on error. bool HandleForkRequest(int fd, base::PickleIterator iter, - ScopedVector<base::ScopedFD> fds); + std::vector<base::ScopedFD> fds); bool HandleGetSandboxStatus(int fd, base::PickleIterator iter); diff --git a/extensions/shell/app/shell_main_delegate.h b/extensions/shell/app/shell_main_delegate.h index 587de92..4a616df 100644 --- a/extensions/shell/app/shell_main_delegate.h +++ b/extensions/shell/app/shell_main_delegate.h @@ -7,6 +7,7 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/scoped_vector.h" #include "content/public/app/content_main_delegate.h" namespace content { diff --git a/sandbox/linux/integration_tests/namespace_unix_domain_socket_unittest.cc b/sandbox/linux/integration_tests/namespace_unix_domain_socket_unittest.cc index 9d79bff1..5e8a239 100644 --- a/sandbox/linux/integration_tests/namespace_unix_domain_socket_unittest.cc +++ b/sandbox/linux/integration_tests/namespace_unix_domain_socket_unittest.cc @@ -10,11 +10,11 @@ #include <sys/wait.h> #include <unistd.h> +#include <utility> #include <vector> #include "base/files/scoped_file.h" #include "base/logging.h" -#include "base/memory/scoped_vector.h" #include "base/posix/eintr_wrapper.h" #include "base/posix/unix_domain_socket_linux.h" #include "base/process/process.h" @@ -95,14 +95,14 @@ void RecvHello(int fd, // Extra receiving buffer space to make sure we really received only // sizeof(kHello) bytes and it wasn't just truncated to fit the buffer. char buf[sizeof(kHello) + 1]; - ScopedVector<base::ScopedFD> message_fds; + std::vector<base::ScopedFD> message_fds; ssize_t n = base::UnixDomainSocket::RecvMsgWithPid( fd, buf, sizeof(buf), &message_fds, sender_pid); CHECK_EQ(sizeof(kHello), static_cast<size_t>(n)); CHECK_EQ(0, memcmp(buf, kHello, sizeof(kHello))); CHECK_EQ(1U, message_fds.size()); if (write_pipe) - write_pipe->swap(*message_fds[0]); + std::swap(*write_pipe, message_fds[0]); } // Check that receiving PIDs works across a fork(). diff --git a/sandbox/linux/syscall_broker/broker_host.cc b/sandbox/linux/syscall_broker/broker_host.cc index 1a0568f..a81a30e 100644 --- a/sandbox/linux/syscall_broker/broker_host.cc +++ b/sandbox/linux/syscall_broker/broker_host.cc @@ -174,7 +174,7 @@ BrokerHost::~BrokerHost() { // that we will then close. // A request should start with an int that will be used as the command type. BrokerHost::RequestStatus BrokerHost::HandleRequest() const { - ScopedVector<base::ScopedFD> fds; + std::vector<base::ScopedFD> fds; char buf[kMaxMessageLength]; errno = 0; const ssize_t msg_len = base::UnixDomainSocket::RecvMsg( @@ -187,13 +187,12 @@ BrokerHost::RequestStatus BrokerHost::HandleRequest() const { // The client should send exactly one file descriptor, on which we // will write the reply. - // TODO(mdempsky): ScopedVector doesn't have 'at()', only 'operator[]'. - if (msg_len < 0 || fds.size() != 1 || fds[0]->get() < 0) { + if (msg_len < 0 || fds.size() != 1 || fds[0].get() < 0) { PLOG(ERROR) << "Error reading message from the client"; return RequestStatus::FAILURE; } - base::ScopedFD temporary_ipc(std::move(*fds[0])); + base::ScopedFD temporary_ipc(std::move(fds[0])); base::Pickle pickle(buf, msg_len); base::PickleIterator iter(pickle); |