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