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

Unified Diff: base/memory/shared_memory_mac.cc

Issue 2859843002: Add a GUID to base::SharedMemoryHandle. (Closed)
Patch Set: fix guid on android. Created 3 years, 7 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/memory/shared_memory_handle_win.cc ('k') | base/memory/shared_memory_mac_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_mac.cc
diff --git a/base/memory/shared_memory_mac.cc b/base/memory/shared_memory_mac.cc
index 2bee9e21c0a5089ebded56fb8041312112ca9c5c..0970fa01cc0737f1ea869b36552d5e455fac8e67 100644
--- a/base/memory/shared_memory_mac.cc
+++ b/base/memory/shared_memory_mac.cc
@@ -25,6 +25,7 @@
#include "base/scoped_generic.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
+#include "base/unguessable_token.h"
#include "build/build_config.h"
#if defined(OS_MACOSX)
@@ -74,7 +75,7 @@ bool MakeMachSharedMemoryHandleReadOnly(SharedMemoryHandle* new_handle,
if (kr != KERN_SUCCESS)
return false;
- *new_handle = SharedMemoryHandle(named_right, size);
+ *new_handle = SharedMemoryHandle(named_right, size, handle.GetGUID());
return true;
}
@@ -149,7 +150,7 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
return false;
if (options.type == SharedMemoryHandle::MACH) {
- shm_ = SharedMemoryHandle(options.size);
+ shm_ = SharedMemoryHandle(options.size, UnguessableToken::Create());
requested_size_ = options.size;
return shm_.IsValid();
}
@@ -187,9 +188,10 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
int readonly_mapped_file = -1;
result = PrepareMapFile(std::move(fp), std::move(readonly_fd), &mapped_file,
&readonly_mapped_file);
- shm_ = SharedMemoryHandle(FileDescriptor(mapped_file, false));
- readonly_shm_ =
- SharedMemoryHandle(FileDescriptor(readonly_mapped_file, false));
+ shm_ = SharedMemoryHandle(FileDescriptor(mapped_file, false),
+ UnguessableToken::Create());
+ readonly_shm_ = SharedMemoryHandle(
+ FileDescriptor(readonly_mapped_file, false), shm_.GetGUID());
return result;
}
@@ -237,8 +239,8 @@ bool SharedMemory::Unmap() {
SharedMemoryHandle SharedMemory::handle() const {
switch (shm_.type_) {
case SharedMemoryHandle::POSIX:
- return SharedMemoryHandle(
- FileDescriptor(shm_.file_descriptor_.fd, false));
+ return SharedMemoryHandle(FileDescriptor(shm_.file_descriptor_.fd, false),
+ shm_.GetGUID());
case SharedMemoryHandle::MACH:
return shm_;
}
« no previous file with comments | « base/memory/shared_memory_handle_win.cc ('k') | base/memory/shared_memory_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698