| 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..c11ec8b28c28423e75e16ac22801b0358ee087da
|
| --- /dev/null
|
| +++ b/content/public/browser/file_descriptor_info.cc
|
| @@ -0,0 +1,55 @@
|
| +// 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::Share(int id, base::PlatformFile fd) {
|
| + AddToMapping(id, fd);
|
| +}
|
| +
|
| +void FileDescriptorInfo::Transfer(int id, base::ScopedFD fd) {
|
| + AddToMapping(id, fd.get());
|
| + owned_descriptors_.push_back(new base::ScopedFD(fd.Pass()));
|
| +}
|
| +
|
| +void FileDescriptorInfo::TransferWithoutMapping(base::ScopedFD fd) {
|
| + owned_descriptors_.push_back(new base::ScopedFD(fd.Pass()));
|
| +}
|
| +
|
| +base::PlatformFile FileDescriptorInfo::GetFDAt(size_t i) const {
|
| + return mapping_[i].first;
|
| +}
|
| +
|
| +int FileDescriptorInfo::GetIDAt(size_t i) const {
|
| + return mapping_[i].second;
|
| +}
|
| +
|
| +void FileDescriptorInfo::AddToMapping(int id, base::PlatformFile fd) {
|
| + DCHECK(mapping_.end() ==
|
| + std::find(mapping_.begin(), mapping_.end(), std::make_pair(fd, id)));
|
| + mapping_.push_back(std::make_pair(fd, id));
|
| +}
|
| +
|
| +const base::FileHandleMappingVector& FileDescriptorInfo::GetMapping() const {
|
| + return mapping_;
|
| +}
|
| +
|
| +base::FileHandleMappingVector FileDescriptorInfo::GetMappingWithIDAdjustment(
|
| + int delta) const {
|
| + base::FileHandleMappingVector result = mapping_;
|
| + // Adding delta to each ID.
|
| + for (unsigned i = 0; i < mapping_.size(); ++i)
|
| + result[i].second += delta;
|
| + return result;
|
| +}
|
| +
|
| +} // namespace content
|
|
|