Chromium Code Reviews| Index: content/public/browser/file_descriptor_info.cc |
| diff --git a/content/public/browser/file_descriptor_info.cc b/content/public/browser/file_descriptor_info.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..93c0d94cf1b9b5e16d7cdf3097a99489caf27d01 |
| --- /dev/null |
| +++ b/content/public/browser/file_descriptor_info.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/public/browser/file_descriptor_info.h" |
| + |
| +namespace content { |
| + |
| +FileDescriptorInfo::FileDescriptorInfo() { |
| +} |
| + |
| +FileDescriptorInfo::~FileDescriptorInfo() { |
| +} |
| + |
| +void FileDescriptorInfo::Transfer(int id, base::ScopedFD fd) { |
| + AddToMapping(id, fd.get()); |
| + owned_descriptors_.push_back(new base::ScopedFD(fd.Pass())); |
| +} |
| + |
| +void FileDescriptorInfo::Share(int id, base::PlatformFile fd) { |
| + AddToMapping(id, fd); |
| +} |
| + |
| +base::PlatformFile FileDescriptorInfo::GetFDAt(size_t i) const { |
| + return descriptors_[i].first; |
| +} |
| + |
| +int FileDescriptorInfo::GetIDAt(size_t i) const { |
| + return descriptors_[i].second; |
| +} |
| + |
| +void FileDescriptorInfo::AddToMapping(int id, base::PlatformFile fd) { |
| + DCHECK(descriptors_.end() == std::find(descriptors_.begin(), |
|
mdempsky
2014/09/22 18:30:51
This check allows duplicate mappings for a single
|
| + descriptors_.end(), |
| + std::make_pair(fd, id))); |
| + descriptors_.push_back(std::make_pair(fd, id)); |
| +} |
| + |
| +} // namespace content |