Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2670)

Unified Diff: base/posix/global_descriptors.h

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/metrics/histogram_macros.h ('k') | base/posix/global_descriptors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « base/metrics/histogram_macros.h ('k') | base/posix/global_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698