1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef BASE_POSIX_GLOBAL_DESCRIPTORS_H_
- #define BASE_POSIX_GLOBAL_DESCRIPTORS_H_
- #include "build/build_config.h"
- #include <vector>
- #include <utility>
- #include <stdint.h>
- #include "base/files/memory_mapped_file.h"
- #include "base/files/scoped_file.h"
- #include "base/memory/singleton.h"
- namespace base {
- class BASE_EXPORT GlobalDescriptors {
- public:
- typedef uint32_t Key;
- struct Descriptor {
- Descriptor(Key key, int fd);
- Descriptor(Key key, int fd, base::MemoryMappedFile::Region region);
-
- Key key;
-
- int fd;
-
- base::MemoryMappedFile::Region region;
- };
- typedef std::vector<Descriptor> Mapping;
-
-
- static const int kBaseDescriptor = 3;
-
- static GlobalDescriptors* GetInstance();
-
- int Get(Key key) const;
-
- int MaybeGet(Key key) const;
-
-
-
- base::ScopedFD TakeFD(Key key, base::MemoryMappedFile::Region* region);
-
- base::MemoryMappedFile::Region GetRegion(Key key) const;
-
-
- void Set(Key key, int fd);
-
- void Set(Key key, int fd, base::MemoryMappedFile::Region region);
- void Reset(const Mapping& mapping);
- private:
- friend struct DefaultSingletonTraits<GlobalDescriptors>;
- GlobalDescriptors();
- ~GlobalDescriptors();
- Mapping descriptors_;
- };
- }
- #endif
|