Index: base/memory/shared_memory_mac_unittest.cc |
diff --git a/base/memory/shared_memory_mac_unittest.cc b/base/memory/shared_memory_mac_unittest.cc |
index bfb0368da666f6d8936a0c1ddced5a0db5bd12be..8e758250d1469b1c6cbba0161972624a48504036 100644 |
--- a/base/memory/shared_memory_mac_unittest.cc |
+++ b/base/memory/shared_memory_mac_unittest.cc |
@@ -20,6 +20,7 @@ |
#include "base/sys_info.h" |
#include "base/test/multiprocess_test.h" |
#include "base/test/test_timeouts.h" |
+#include "base/unguessable_token.h" |
#include "testing/multiprocess_func_list.h" |
namespace base { |
@@ -55,7 +56,7 @@ bool GetProtections(void* address, size_t size, int* current, int* max) { |
// Creates a new SharedMemory with the given |size|, filled with 'a'. |
std::unique_ptr<SharedMemory> CreateSharedMemory(int size) { |
- SharedMemoryHandle shm(size); |
+ SharedMemoryHandle shm(size, UnguessableToken::Create()); |
if (!shm.IsValid()) { |
LOG(ERROR) << "Failed to make SharedMemoryHandle"; |
return nullptr; |
@@ -247,7 +248,8 @@ MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryClient) { |
// The next mach port should be for a memory object. |
mach_port_t memory_object = ReceiveMachPort(client_port.get()); |
SharedMemoryHandle shm(memory_object, |
- SharedMemoryMacMultiProcessTest::s_memory_size); |
+ SharedMemoryMacMultiProcessTest::s_memory_size, |
+ UnguessableToken::Create()); |
SharedMemory shared_memory(shm, false); |
shared_memory.Map(SharedMemoryMacMultiProcessTest::s_memory_size); |
const char* start = static_cast<const char*>(shared_memory.memory()); |
@@ -261,7 +263,7 @@ MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryClient) { |
TEST_F(SharedMemoryMacMultiProcessTest, MachBasedSharedMemoryWithOffset) { |
SetUpChild("MachBasedSharedMemoryWithOffsetClient"); |
- SharedMemoryHandle shm(s_memory_size); |
+ SharedMemoryHandle shm(s_memory_size, UnguessableToken::Create()); |
ASSERT_TRUE(shm.IsValid()); |
SharedMemory shared_memory(shm, false); |
shared_memory.Map(s_memory_size); |
@@ -286,7 +288,8 @@ MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryWithOffsetClient) { |
// The next mach port should be for a memory object. |
mach_port_t memory_object = ReceiveMachPort(client_port.get()); |
SharedMemoryHandle shm(memory_object, |
- SharedMemoryMacMultiProcessTest::s_memory_size); |
+ SharedMemoryMacMultiProcessTest::s_memory_size, |
+ UnguessableToken::Create()); |
SharedMemory shared_memory(shm, false); |
size_t page_size = SysInfo::VMAllocationGranularity(); |
shared_memory.MapAt(page_size, 2 * page_size); |
@@ -306,7 +309,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachDuplicateAndClose) { |
mach_msg_type_number_t active_name_count = GetActiveNameCount(); |
// Making a new SharedMemoryHandle increments the name count. |
- SharedMemoryHandle shm(s_memory_size); |
+ SharedMemoryHandle shm(s_memory_size, UnguessableToken::Create()); |
ASSERT_TRUE(shm.IsValid()); |
EXPECT_EQ(active_name_count + 1, GetActiveNameCount()); |
@@ -345,7 +348,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachSharedMemoryTakesOwnership) { |
mach_msg_type_number_t active_name_count = GetActiveNameCount(); |
// Making a new SharedMemoryHandle increments the name count. |
- SharedMemoryHandle shm(s_memory_size); |
+ SharedMemoryHandle shm(s_memory_size, UnguessableToken::Create()); |
ASSERT_TRUE(shm.IsValid()); |
EXPECT_EQ(active_name_count + 1, GetActiveNameCount()); |
@@ -408,6 +411,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachReadonly) { |
// Make a new memory object. |
SharedMemoryHandle shm2 = shared_memory->GetReadOnlyHandle(); |
ASSERT_TRUE(shm2.IsValid()); |
+ EXPECT_EQ(shared_memory->handle().GetGUID(), shm2.GetGUID()); |
// Mapping with |readonly| set to |false| should fail. |
SharedMemory shared_memory2(shm2, false); |