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

Unified Diff: content/browser/file_descriptor_info_impl.cc

Issue 909553003: Android: Get rid of extra dup()s on launching child processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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/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 c1f055bc76db322c496ad01cca6f87989d275a74..45ce54246ec7e1cd90df793953cc9ca23e75cfa5 100644
--- a/content/browser/file_descriptor_info_impl.cc
+++ b/content/browser/file_descriptor_info_impl.cc
@@ -47,6 +47,27 @@ bool FileDescriptorInfoImpl::HasID(int id) const {
return false;
}
+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; });
+}
+
+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; });
+
+ (*found)->swap(fd);
+ owned_descriptors_.erase(found);
+
+ return fd.Pass();
+}
+
void FileDescriptorInfoImpl::AddToMapping(int id, base::PlatformFile fd) {
DCHECK(!HasID(id));
mapping_.push_back(std::make_pair(fd, id));

Powered by Google App Engine
This is Rietveld 408576698