Chromium Code Reviews| Index: base/memory/shared_memory_posix.cc |
| diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc |
| index 0444e59dba1c9f5ca52df331126ecbf8c47ea6f8..4307a77d94857e5871f9b5c42372e0737d80bc86 100644 |
| --- a/base/memory/shared_memory_posix.cc |
| +++ b/base/memory/shared_memory_posix.cc |
| @@ -23,6 +23,7 @@ |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "base/trace_event/trace_event.h" |
| +#include "base/unguessable_token.h" |
| #include "build/build_config.h" |
| #if defined(OS_ANDROID) |
| @@ -211,8 +212,10 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) { |
| int readonly_mapped_file = -1; |
| bool result = PrepareMapFile(std::move(fp), std::move(readonly_fd), |
| &mapped_file, &readonly_mapped_file); |
| - shm_ = SharedMemoryHandle::ImportHandle(mapped_file); |
| - readonly_shm_ = SharedMemoryHandle::ImportHandle(readonly_mapped_file); |
| + shm_ = SharedMemoryHandle(base::FileDescriptor(mapped_file, false), |
| + UnguessableToken::Create()); |
| + readonly_shm_ = SharedMemoryHandle( |
| + base::FileDescriptor(readonly_mapped_file, false), shm_.GetGUID()); |
|
Nico
2017/05/05 18:34:36
For posix too I suppose, not just mac.
erikchen
2017/05/05 19:29:32
Done.
|
| return result; |
| } |
| @@ -249,8 +252,13 @@ bool SharedMemory::Open(const std::string& name, bool read_only) { |
| int readonly_mapped_file = -1; |
| bool result = PrepareMapFile(std::move(fp), std::move(readonly_fd), |
| &mapped_file, &readonly_mapped_file); |
| - shm_ = SharedMemoryHandle::ImportHandle(mapped_file); |
| - readonly_shm_ = SharedMemoryHandle::ImportHandle(readonly_mapped_file); |
| + // This form of sharing shared memory is deprecated. https://crbug.com/345734. |
| + // Technically, we should also pass the GUID from the original shared memory |
| + // region. Instead, we should just remove all instances of this. |
|
Nico
2017/05/05 18:34:36
Your last comment sounds like you no longer think
erikchen
2017/05/05 19:29:32
Done.
|
| + shm_ = SharedMemoryHandle(base::FileDescriptor(mapped_file, false), |
| + UnguessableToken::Create()); |
| + readonly_shm_ = SharedMemoryHandle( |
| + base::FileDescriptor(readonly_mapped_file, false), shm_.GetGUID()); |
| return result; |
| } |
| #endif // !defined(OS_ANDROID) |