| 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/memory/ptr_util.h" |
| 9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 | 13 |
| 13 // static | 14 // static |
| 14 std::unique_ptr<FileDescriptorInfo> FileDescriptorInfoImpl::Create() { | 15 std::unique_ptr<FileDescriptorInfo> FileDescriptorInfoImpl::Create() { |
| 15 return std::unique_ptr<FileDescriptorInfo>(new FileDescriptorInfoImpl()); | 16 return std::unique_ptr<FileDescriptorInfo>(new FileDescriptorInfoImpl()); |
| 16 } | 17 } |
| 17 | 18 |
| 18 FileDescriptorInfoImpl::FileDescriptorInfoImpl() { | 19 FileDescriptorInfoImpl::FileDescriptorInfoImpl() { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 mapping_.push_back(std::make_pair(fd, id)); | 87 mapping_.push_back(std::make_pair(fd, id)); |
| 87 if (region != base::MemoryMappedFile::Region::kWholeFile) | 88 if (region != base::MemoryMappedFile::Region::kWholeFile) |
| 88 ids_to_regions_[id] = region; | 89 ids_to_regions_[id] = region; |
| 89 } | 90 } |
| 90 | 91 |
| 91 const base::FileHandleMappingVector& FileDescriptorInfoImpl::GetMapping() | 92 const base::FileHandleMappingVector& FileDescriptorInfoImpl::GetMapping() |
| 92 const { | 93 const { |
| 93 return mapping_; | 94 return mapping_; |
| 94 } | 95 } |
| 95 | 96 |
| 96 base::FileHandleMappingVector | 97 std::unique_ptr<base::FileHandleMappingVector> |
| 97 FileDescriptorInfoImpl::GetMappingWithIDAdjustment(int delta) const { | 98 FileDescriptorInfoImpl::GetMappingWithIDAdjustment(int delta) const { |
| 98 base::FileHandleMappingVector result = mapping_; | 99 std::unique_ptr<base::FileHandleMappingVector> result = |
| 100 base::MakeUnique<base::FileHandleMappingVector>(mapping_); |
| 99 // Adding delta to each ID. | 101 // Adding delta to each ID. |
| 100 for (unsigned i = 0; i < mapping_.size(); ++i) | 102 for (unsigned i = 0; i < mapping_.size(); ++i) |
| 101 result[i].second += delta; | 103 (*result)[i].second += delta; |
| 102 return result; | 104 return result; |
| 103 } | 105 } |
| 104 | 106 |
| 105 } // namespace content | 107 } // namespace content |
| OLD | NEW |