Index: base/memory/shared_memory_handle.h |
diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h |
index 044c9c983a6c0fdc60461d9820befc61b315d172..56165b403b9b18b7eafead80e853c32c51e95bab 100644 |
--- a/base/memory/shared_memory_handle.h |
+++ b/base/memory/shared_memory_handle.h |
@@ -7,6 +7,7 @@ |
#include <stddef.h> |
+#include "base/unguessable_token.h" |
#include "build/build_config.h" |
#if defined(OS_WIN) |
@@ -61,6 +62,8 @@ class BASE_EXPORT SharedMemoryHandle { |
// resource. |
SharedMemoryHandle Duplicate() const; |
+ base::UnguessableToken GetGUID() const; |
Nico
2017/05/04 17:42:13
add comment saying what this is good for
erikchen
2017/05/04 19:21:13
Done.
|
+ |
#if defined(OS_MACOSX) && !defined(OS_IOS) |
enum Type { |
// The SharedMemoryHandle is backed by a POSIX fd. |
@@ -76,15 +79,18 @@ class BASE_EXPORT SharedMemoryHandle { |
// common for existing code to make shallow copies of SharedMemoryHandle, and |
// the one that is finally passed into a base::SharedMemory is the one that |
// "consumes" the fd. |
Nico
2017/05/04 17:42:13
mention what the guid is for (can people who don't
erikchen
2017/05/04 19:21:12
Done.
|
- explicit SharedMemoryHandle(const base::FileDescriptor& file_descriptor); |
+ SharedMemoryHandle(const base::FileDescriptor& file_descriptor, |
+ const base::UnguessableToken& guid); |
// Makes a Mach-based SharedMemoryHandle of the given size. On error, |
// subsequent calls to IsValid() return false. |
- explicit SharedMemoryHandle(mach_vm_size_t size); |
+ SharedMemoryHandle(mach_vm_size_t size, const base::UnguessableToken& guid); |
// Makes a Mach-based SharedMemoryHandle from |memory_object|, a named entry |
// in the current task. The memory region has size |size|. |
- SharedMemoryHandle(mach_port_t memory_object, mach_vm_size_t size); |
+ SharedMemoryHandle(mach_port_t memory_object, |
+ mach_vm_size_t size, |
+ const base::UnguessableToken& guid); |
// Exposed so that the SharedMemoryHandle can be transported between |
// processes. |
@@ -100,16 +106,12 @@ class BASE_EXPORT SharedMemoryHandle { |
// mapped memory. |
bool MapAt(off_t offset, size_t bytes, void** memory, bool read_only); |
#elif defined(OS_WIN) |
- // Takes implicit ownership of |h|. |
- SharedMemoryHandle(HANDLE h); |
- |
+ // Takes implicit ownership of |h|, with the given |guid|. |
+ SharedMemoryHandle(HANDLE h, const base::UnguessableToken& guid); |
HANDLE GetHandle() const; |
#else |
- // This constructor is deprecated, as it fails to propagate the GUID, which |
- // will be added in the near future. |
- // TODO(rockot): Remove this constructor once Mojo supports GUIDs. |
- // https://crbug.com/713763. |
- explicit SharedMemoryHandle(const base::FileDescriptor& file_descriptor); |
+ SharedMemoryHandle(const base::FileDescriptor& file_descriptor, |
+ const base::UnguessableToken& guid); |
// Creates a SharedMemoryHandle from an |fd| supplied from an external |
// service. |
@@ -130,9 +132,6 @@ class BASE_EXPORT SharedMemoryHandle { |
#if defined(OS_MACOSX) && !defined(OS_IOS) |
friend class SharedMemory; |
- // Shared code between copy constructor and operator=. |
- void CopyRelevantData(const SharedMemoryHandle& handle); |
- |
Type type_; |
// Each instance of a SharedMemoryHandle is backed either by a POSIX fd or a |
@@ -166,6 +165,9 @@ class BASE_EXPORT SharedMemoryHandle { |
#else |
FileDescriptor file_descriptor_; |
#endif |
+ |
+ // Uniques identifies the SharedMemoryHandle. Preserved across IPC. |
+ base::UnguessableToken guid_; |
}; |
} // namespace base |