| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/file_descriptor_info_impl.h" | 5 #include "content/browser/file_descriptor_info_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 bool FileDescriptorInfoImpl::HasID(int id) const { | 45 bool FileDescriptorInfoImpl::HasID(int id) const { |
| 46 for (unsigned i = 0; i < mapping_.size(); ++i) { | 46 for (unsigned i = 0; i < mapping_.size(); ++i) { |
| 47 if (mapping_[i].second == id) | 47 if (mapping_[i].second == id) |
| 48 return true; | 48 return true; |
| 49 } | 49 } |
| 50 | 50 |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool FileDescriptorInfoImpl::OwnsFD(base::PlatformFile file) const { | 54 bool FileDescriptorInfoImpl::OwnsFD(base::PlatformFile file) const { |
| 55 return ContainsValue(owned_descriptors_, file); | 55 return base::ContainsValue(owned_descriptors_, file); |
| 56 } | 56 } |
| 57 | 57 |
| 58 base::ScopedFD FileDescriptorInfoImpl::ReleaseFD(base::PlatformFile file) { | 58 base::ScopedFD FileDescriptorInfoImpl::ReleaseFD(base::PlatformFile file) { |
| 59 DCHECK(OwnsFD(file)); | 59 DCHECK(OwnsFD(file)); |
| 60 | 60 |
| 61 base::ScopedFD fd; | 61 base::ScopedFD fd; |
| 62 auto found = | 62 auto found = |
| 63 std::find(owned_descriptors_.begin(), owned_descriptors_.end(), file); | 63 std::find(owned_descriptors_.begin(), owned_descriptors_.end(), file); |
| 64 | 64 |
| 65 std::swap(*found, fd); | 65 std::swap(*found, fd); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 81 base::FileHandleMappingVector | 81 base::FileHandleMappingVector |
| 82 FileDescriptorInfoImpl::GetMappingWithIDAdjustment(int delta) const { | 82 FileDescriptorInfoImpl::GetMappingWithIDAdjustment(int delta) const { |
| 83 base::FileHandleMappingVector result = mapping_; | 83 base::FileHandleMappingVector result = mapping_; |
| 84 // Adding delta to each ID. | 84 // Adding delta to each ID. |
| 85 for (unsigned i = 0; i < mapping_.size(); ++i) | 85 for (unsigned i = 0; i < mapping_.size(); ++i) |
| 86 result[i].second += delta; | 86 result[i].second += delta; |
| 87 return result; | 87 return result; |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace content | 90 } // namespace content |
| OLD | NEW |