Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/public/browser/file_descriptor_info.h" | |
| 6 | |
| 7 namespace content { | |
| 8 | |
| 9 FileDescriptorInfo::FileDescriptorInfo() { | |
| 10 } | |
| 11 | |
| 12 FileDescriptorInfo::~FileDescriptorInfo() { | |
| 13 } | |
| 14 | |
| 15 void FileDescriptorInfo::Transfer(int id, base::ScopedFD fd) { | |
| 16 AddToMapping(id, fd.get()); | |
| 17 owned_descriptors_.push_back(new base::ScopedFD(fd.Pass())); | |
| 18 } | |
| 19 | |
| 20 void FileDescriptorInfo::Share(int id, base::PlatformFile fd) { | |
| 21 AddToMapping(id, fd); | |
| 22 } | |
| 23 | |
| 24 base::PlatformFile FileDescriptorInfo::GetFDAt(size_t i) const { | |
| 25 return descriptors_[i].first; | |
| 26 } | |
| 27 | |
| 28 int FileDescriptorInfo::GetIDAt(size_t i) const { | |
| 29 return descriptors_[i].second; | |
| 30 } | |
| 31 | |
| 32 void FileDescriptorInfo::AddToMapping(int id, base::PlatformFile fd) { | |
| 33 DCHECK(descriptors_.end() == std::find(descriptors_.begin(), | |
|
mdempsky
2014/09/22 18:30:51
This check allows duplicate mappings for a single
| |
| 34 descriptors_.end(), | |
| 35 std::make_pair(fd, id))); | |
| 36 descriptors_.push_back(std::make_pair(fd, id)); | |
| 37 } | |
| 38 | |
| 39 } // namespace content | |
| OLD | NEW |