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