| 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 #ifndef CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ |
| 6 #define CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ | 6 #define CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/files/memory_mapped_file.h" | 14 #include "base/files/memory_mapped_file.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/file_descriptor_info.h" | 16 #include "content/public/browser/file_descriptor_info.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class FileDescriptorInfoImpl : public FileDescriptorInfo { | 20 class FileDescriptorInfoImpl : public FileDescriptorInfo { |
| 21 public: | 21 public: |
| 22 CONTENT_EXPORT static std::unique_ptr<FileDescriptorInfo> Create(); | 22 CONTENT_EXPORT static std::unique_ptr<FileDescriptorInfo> Create(); |
| 23 | 23 |
| 24 ~FileDescriptorInfoImpl() override; | 24 ~FileDescriptorInfoImpl() override; |
| 25 void Share(int id, base::PlatformFile fd) override; | 25 void Share(int id, base::PlatformFile fd) override; |
| 26 void ShareWithRegion(int id, base::PlatformFile fd, | 26 void ShareWithRegion(int id, base::PlatformFile fd, |
| 27 const base::MemoryMappedFile::Region& region) override; | 27 const base::MemoryMappedFile::Region& region) override; |
| 28 void Transfer(int id, base::ScopedFD fd) override; | 28 void Transfer(int id, base::ScopedFD fd) override; |
| 29 const base::FileHandleMappingVector& GetMapping() const override; | 29 const base::FileHandleMappingVector& GetMapping() const override; |
| 30 base::FileHandleMappingVector GetMappingWithIDAdjustment( | 30 std::unique_ptr<base::FileHandleMappingVector> GetMappingWithIDAdjustment( |
| 31 int delta) const override; | 31 int delta) const override; |
| 32 base::PlatformFile GetFDAt(size_t i) const override; | 32 base::PlatformFile GetFDAt(size_t i) const override; |
| 33 int GetIDAt(size_t i) const override; | 33 int GetIDAt(size_t i) const override; |
| 34 const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const override; | 34 const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const override; |
| 35 size_t GetMappingSize() const override; | 35 size_t GetMappingSize() const override; |
| 36 bool OwnsFD(base::PlatformFile file) const override; | 36 bool OwnsFD(base::PlatformFile file) const override; |
| 37 base::ScopedFD ReleaseFD(base::PlatformFile file) override; | 37 base::ScopedFD ReleaseFD(base::PlatformFile file) override; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 FileDescriptorInfoImpl(); | 40 FileDescriptorInfoImpl(); |
| 41 | 41 |
| 42 void AddToMapping(int id, base::PlatformFile fd, | 42 void AddToMapping(int id, base::PlatformFile fd, |
| 43 const base::MemoryMappedFile::Region& region); | 43 const base::MemoryMappedFile::Region& region); |
| 44 bool HasID(int id) const; | 44 bool HasID(int id) const; |
| 45 base::FileHandleMappingVector mapping_; | 45 base::FileHandleMappingVector mapping_; |
| 46 // Maps the ID of a FD to the region to use for that FD, the whole file if not | 46 // Maps the ID of a FD to the region to use for that FD, the whole file if not |
| 47 // in the map. | 47 // in the map. |
| 48 std::map<int, base::MemoryMappedFile::Region> ids_to_regions_; | 48 std::map<int, base::MemoryMappedFile::Region> ids_to_regions_; |
| 49 std::vector<base::ScopedFD> owned_descriptors_; | 49 std::vector<base::ScopedFD> owned_descriptors_; |
| 50 }; | 50 }; |
| 51 } | 51 } |
| 52 | 52 |
| 53 #endif // CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ | 53 #endif // CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ |
| OLD | NEW |