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

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

Issue 1472313002: Revert of base: Make shared memory backed by Mach primitives by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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') | content/browser/loader/resource_buffer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/atomicops.h" 5 #include "base/atomicops.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 // This test is not applicable for iOS (crbug.com/399384). 466 // This test is not applicable for iOS (crbug.com/399384).
467 #if !defined(OS_IOS) 467 #if !defined(OS_IOS)
468 // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC. 468 // Create a shared memory object, mmap it, and mprotect it to PROT_EXEC.
469 TEST(SharedMemoryTest, AnonymousExecutable) { 469 TEST(SharedMemoryTest, AnonymousExecutable) {
470 const uint32 kTestSize = 1 << 16; 470 const uint32 kTestSize = 1 << 16;
471 471
472 SharedMemory shared_memory; 472 SharedMemory shared_memory;
473 SharedMemoryCreateOptions options; 473 SharedMemoryCreateOptions options;
474 options.size = kTestSize; 474 options.size = kTestSize;
475 options.executable = true; 475 options.executable = true;
476 #if defined(OS_MACOSX) && !defined(OS_IOS)
477 // The Mach functionality is tested in shared_memory_mac_unittest.cc.
478 options.type = SharedMemoryHandle::POSIX;
479 #endif
480 476
481 EXPECT_TRUE(shared_memory.Create(options)); 477 EXPECT_TRUE(shared_memory.Create(options));
482 EXPECT_TRUE(shared_memory.Map(shared_memory.requested_size())); 478 EXPECT_TRUE(shared_memory.Map(shared_memory.requested_size()));
483 479
484 EXPECT_EQ(0, mprotect(shared_memory.memory(), shared_memory.requested_size(), 480 EXPECT_EQ(0, mprotect(shared_memory.memory(), shared_memory.requested_size(),
485 PROT_READ | PROT_EXEC)); 481 PROT_READ | PROT_EXEC));
486 } 482 }
487 #endif // !defined(OS_IOS) 483 #endif // !defined(OS_IOS)
488 484
489 // Android supports a different permission model than POSIX for its "ashmem" 485 // Android supports a different permission model than POSIX for its "ashmem"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 memory.Close(); 641 memory.Close();
646 SharedMemoryProcessTest::CleanUp(); 642 SharedMemoryProcessTest::CleanUp();
647 } 643 }
648 644
649 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) { 645 MULTIPROCESS_TEST_MAIN(SharedMemoryTestMain) {
650 return SharedMemoryProcessTest::TaskTestMain(); 646 return SharedMemoryProcessTest::TaskTestMain();
651 } 647 }
652 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX) 648 #endif // !defined(OS_IOS) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
653 649
654 } // namespace base 650 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/shared_memory_mac.cc ('k') | content/browser/loader/resource_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698