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

Unified Diff: content/browser/file_descriptor_info_impl.cc

Issue 1508213002: Replace ScopedVector<ScopedFD> with std::vector<ScopedFD> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: danakj feedback 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
« no previous file with comments | « content/browser/file_descriptor_info_impl.h ('k') | content/browser/renderer_host/sandbox_ipc_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/file_descriptor_info_impl.cc
diff --git a/content/browser/file_descriptor_info_impl.cc b/content/browser/file_descriptor_info_impl.cc
index c6cf831e6258333c8a3a1ad148d1bca7a8440ef5..f071b426d5850318d481bb2592ae119022a7ef6f 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;
« no previous file with comments | « content/browser/file_descriptor_info_impl.h ('k') | content/browser/renderer_host/sandbox_ipc_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698