| Index: base/posix/global_descriptors.h
|
| diff --git a/base/posix/global_descriptors.h b/base/posix/global_descriptors.h
|
| index 3d7369c3174a9e8f0df4b0cdd85c4428111a94db..c774634f59bf9c45bd9acce2a7762de19b3b257b 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:
|
|
|