| Index: base/posix/global_descriptors.cc
|
| diff --git a/base/posix/global_descriptors.cc b/base/posix/global_descriptors.cc
|
| index 6c187838ad69d63051a1155d64c26623de8a2db0..815250809184f28f01acc84ceecac192ede77f4a 100644
|
| --- a/base/posix/global_descriptors.cc
|
| +++ b/base/posix/global_descriptors.cc
|
| @@ -8,6 +8,7 @@
|
| #include <utility>
|
|
|
| #include "base/logging.h"
|
| +#include "base/rand_util.h"
|
|
|
| namespace base {
|
|
|
| @@ -65,6 +66,16 @@ void GlobalDescriptors::Set(Key key,
|
| descriptors_.push_back(Descriptor(key, fd, region));
|
| }
|
|
|
| +GlobalDescriptors::Key GlobalDescriptors::Register(int fd) {
|
| + // Find a random unused key.
|
| + Key key;
|
| + do {
|
| + base::RandBytes(&key, sizeof(Key));
|
| + } while (MaybeGet(key) != -1);
|
| + Set(key, fd);
|
| + return key;
|
| +}
|
| +
|
| base::MemoryMappedFile::Region GlobalDescriptors::GetRegion(Key key) const {
|
| for (const auto& i : descriptors_) {
|
| if (i.key == key)
|
|
|