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

Unified Diff: base/posix/global_descriptors.cc

Issue 2549363004: Multiprocess test client: Android child process launcher rework. (Closed)
Patch Set: Fixed tests Created 4 years 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
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)

Powered by Google App Engine
This is Rietveld 408576698