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/posix_file_descriptor_info.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class FileDescriptorInfoImpl : public FileDescriptorInfo { | 20 class PosixFileDescriptorInfoImpl : public PosixFileDescriptorInfo { |
21 public: | 21 public: |
22 CONTENT_EXPORT static std::unique_ptr<FileDescriptorInfo> Create(); | 22 CONTENT_EXPORT static std::unique_ptr<PosixFileDescriptorInfo> Create(); |
23 | 23 |
24 ~FileDescriptorInfoImpl() override; | 24 ~PosixFileDescriptorInfoImpl() 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, |
27 const base::MemoryMappedFile::Region& region) override; | 27 base::PlatformFile fd, |
| 28 const base::MemoryMappedFile::Region& region) override; |
28 void Transfer(int id, base::ScopedFD fd) override; | 29 void Transfer(int id, base::ScopedFD fd) override; |
29 const base::FileHandleMappingVector& GetMapping() const override; | 30 const base::FileHandleMappingVector& GetMapping() const override; |
30 std::unique_ptr<base::FileHandleMappingVector> GetMappingWithIDAdjustment( | 31 base::FileHandleMappingVector GetMappingWithIDAdjustment( |
31 int delta) const override; | 32 int delta) const override; |
32 base::PlatformFile GetFDAt(size_t i) const override; | 33 base::PlatformFile GetFDAt(size_t i) const override; |
33 int GetIDAt(size_t i) const override; | 34 int GetIDAt(size_t i) const override; |
34 const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const override; | 35 const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const override; |
35 size_t GetMappingSize() const override; | 36 size_t GetMappingSize() const override; |
36 bool OwnsFD(base::PlatformFile file) const override; | 37 bool OwnsFD(base::PlatformFile file) const override; |
37 base::ScopedFD ReleaseFD(base::PlatformFile file) override; | 38 base::ScopedFD ReleaseFD(base::PlatformFile file) override; |
38 | 39 |
39 private: | 40 private: |
40 FileDescriptorInfoImpl(); | 41 PosixFileDescriptorInfoImpl(); |
41 | 42 |
42 void AddToMapping(int id, base::PlatformFile fd, | 43 void AddToMapping(int id, |
43 const base::MemoryMappedFile::Region& region); | 44 base::PlatformFile fd, |
| 45 const base::MemoryMappedFile::Region& region); |
44 bool HasID(int id) const; | 46 bool HasID(int id) const; |
45 base::FileHandleMappingVector mapping_; | 47 base::FileHandleMappingVector mapping_; |
46 // Maps the ID of a FD to the region to use for that FD, the whole file if not | 48 // Maps the ID of a FD to the region to use for that FD, the whole file if not |
47 // in the map. | 49 // in the map. |
48 std::map<int, base::MemoryMappedFile::Region> ids_to_regions_; | 50 std::map<int, base::MemoryMappedFile::Region> ids_to_regions_; |
49 std::vector<base::ScopedFD> owned_descriptors_; | 51 std::vector<base::ScopedFD> owned_descriptors_; |
50 }; | 52 }; |
51 } | 53 } // namespace content |
52 | 54 |
53 #endif // CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ | 55 #endif // CONTENT_BROWSER_FILE_DESCRIPTOR_INFO_IMPL_H_ |
OLD | NEW |