diff options
Diffstat (limited to 'base/posix/global_descriptors.h')
-rw-r--r-- | base/posix/global_descriptors.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/base/posix/global_descriptors.h b/base/posix/global_descriptors.h index 3d7369c31..c774634 100644 --- a/base/posix/global_descriptors.h +++ b/base/posix/global_descriptors.h @@ -12,6 +12,7 @@ #include <stdint.h> +#include "base/files/memory_mapped_file.h" #include "base/memory/singleton.h" namespace base { @@ -36,8 +37,18 @@ namespace base { class BASE_EXPORT GlobalDescriptors { public: typedef uint32_t Key; - typedef std::pair<Key, int> KeyFDPair; - typedef std::vector<KeyFDPair> Mapping; + struct Descriptor { + Descriptor(Key key, int fd); + Descriptor(Key key, int fd, base::MemoryMappedFile::Region region); + + // Globally unique key. + Key key; + // Actual FD. + int fd; + // Optional region, defaults to kWholeFile. + base::MemoryMappedFile::Region region; + }; + typedef std::vector<Descriptor> Mapping; // Often we want a canonical descriptor for a given Key. In this case, we add // the following constant to the key value: @@ -53,12 +64,19 @@ class BASE_EXPORT GlobalDescriptors { // Get a descriptor given a key. It is a fatal error if the key is not known. int Get(Key key) const; - // Get a descriptor give a key. Returns -1 on error. + // Get a descriptor given a key. Returns -1 on error. int MaybeGet(Key key) const; - // Set the descriptor for the given key. + // Get a region given a key. It is a fatal error if the key is not known. + base::MemoryMappedFile::Region GetRegion(Key key) const; + + // Set the descriptor for the given |key|. This sets the region associated + // with |key| to kWholeFile. void Set(Key key, int fd); + // Set the descriptor and |region| for the given |key|. + void Set(Key key, int fd, base::MemoryMappedFile::Region region); + void Reset(const Mapping& mapping); private: |