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

Side by Side Diff: base/memory/shared_memory_mac_unittest.cc

Issue 2849243002: Get rid of all pid references from base::SharedMemoryHandle. (Closed)
Patch Set: fix invalid handle Chrome IPC. 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 unified diff | Download patch
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | base/memory/shared_memory_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <mach/mach.h> 5 #include <mach/mach.h>
6 #include <mach/mach_vm.h> 6 #include <mach/mach_vm.h>
7 #include <servers/bootstrap.h> 7 #include <servers/bootstrap.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 ASSERT_TRUE(spawn_child_.process.WaitForExitWithTimeout( 240 ASSERT_TRUE(spawn_child_.process.WaitForExitWithTimeout(
241 TestTimeouts::action_timeout(), &rv)); 241 TestTimeouts::action_timeout(), &rv));
242 EXPECT_EQ(0, rv); 242 EXPECT_EQ(0, rv);
243 } 243 }
244 244
245 MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryClient) { 245 MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryClient) {
246 mac::ScopedMachReceiveRight client_port(CommonChildProcessSetUp()); 246 mac::ScopedMachReceiveRight client_port(CommonChildProcessSetUp());
247 // The next mach port should be for a memory object. 247 // The next mach port should be for a memory object.
248 mach_port_t memory_object = ReceiveMachPort(client_port.get()); 248 mach_port_t memory_object = ReceiveMachPort(client_port.get());
249 SharedMemoryHandle shm(memory_object, 249 SharedMemoryHandle shm(memory_object,
250 SharedMemoryMacMultiProcessTest::s_memory_size, 250 SharedMemoryMacMultiProcessTest::s_memory_size);
251 GetCurrentProcId());
252 SharedMemory shared_memory(shm, false); 251 SharedMemory shared_memory(shm, false);
253 shared_memory.Map(SharedMemoryMacMultiProcessTest::s_memory_size); 252 shared_memory.Map(SharedMemoryMacMultiProcessTest::s_memory_size);
254 const char* start = static_cast<const char*>(shared_memory.memory()); 253 const char* start = static_cast<const char*>(shared_memory.memory());
255 for (int i = 0; i < SharedMemoryMacMultiProcessTest::s_memory_size; ++i) { 254 for (int i = 0; i < SharedMemoryMacMultiProcessTest::s_memory_size; ++i) {
256 DCHECK_EQ(start[i], 'a'); 255 DCHECK_EQ(start[i], 'a');
257 } 256 }
258 return 0; 257 return 0;
259 } 258 }
260 259
261 // Tests that mapping shared memory with an offset works correctly. 260 // Tests that mapping shared memory with an offset works correctly.
(...skipping 18 matching lines...) Expand all
280 ASSERT_TRUE(spawn_child_.process.WaitForExitWithTimeout( 279 ASSERT_TRUE(spawn_child_.process.WaitForExitWithTimeout(
281 TestTimeouts::action_timeout(), &rv)); 280 TestTimeouts::action_timeout(), &rv));
282 EXPECT_EQ(0, rv); 281 EXPECT_EQ(0, rv);
283 } 282 }
284 283
285 MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryWithOffsetClient) { 284 MULTIPROCESS_TEST_MAIN(MachBasedSharedMemoryWithOffsetClient) {
286 mac::ScopedMachReceiveRight client_port(CommonChildProcessSetUp()); 285 mac::ScopedMachReceiveRight client_port(CommonChildProcessSetUp());
287 // The next mach port should be for a memory object. 286 // The next mach port should be for a memory object.
288 mach_port_t memory_object = ReceiveMachPort(client_port.get()); 287 mach_port_t memory_object = ReceiveMachPort(client_port.get());
289 SharedMemoryHandle shm(memory_object, 288 SharedMemoryHandle shm(memory_object,
290 SharedMemoryMacMultiProcessTest::s_memory_size, 289 SharedMemoryMacMultiProcessTest::s_memory_size);
291 GetCurrentProcId());
292 SharedMemory shared_memory(shm, false); 290 SharedMemory shared_memory(shm, false);
293 size_t page_size = SysInfo::VMAllocationGranularity(); 291 size_t page_size = SysInfo::VMAllocationGranularity();
294 shared_memory.MapAt(page_size, 2 * page_size); 292 shared_memory.MapAt(page_size, 2 * page_size);
295 const char* start = static_cast<const char*>(shared_memory.memory()); 293 const char* start = static_cast<const char*>(shared_memory.memory());
296 for (size_t i = 0; i < page_size; ++i) { 294 for (size_t i = 0; i < page_size; ++i) {
297 DCHECK_EQ(start[i], 'b'); 295 DCHECK_EQ(start[i], 'b');
298 } 296 }
299 for (size_t i = page_size; i < 2 * page_size; ++i) { 297 for (size_t i = page_size; i < 2 * page_size; ++i) {
300 DCHECK_EQ(start[i], 'c'); 298 DCHECK_EQ(start[i], 'c');
301 } 299 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 444
447 // Intentionally map with |readonly| set to |false|. 445 // Intentionally map with |readonly| set to |false|.
448 SharedMemory shared_memory2(shm2, false); 446 SharedMemory shared_memory2(shm2, false);
449 shared_memory2.Map(s_memory_size); 447 shared_memory2.Map(s_memory_size);
450 } 448 }
451 449
452 EXPECT_EQ(active_name_count, GetActiveNameCount()); 450 EXPECT_EQ(active_name_count, GetActiveNameCount());
453 } 451 }
454 452
455 } // namespace base 453 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | base/memory/shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698