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

Side by Side Diff: content/public/browser/file_descriptor_info.cc

Issue 585203002: Turn FileDescriptorInfo a collection class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698