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

Unified Diff: base/memory/discardable_shared_memory_unittest.cc

Issue 2852803002: Remove base::SharedMemory::ShareToProcess. (Closed)
Patch Set: Compile error. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/discardable_shared_memory.h ('k') | base/memory/shared_memory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_shared_memory_unittest.cc
diff --git a/base/memory/discardable_shared_memory_unittest.cc b/base/memory/discardable_shared_memory_unittest.cc
index 4c55d54de21dc6c2fc10d8c451df0abeb2c71604..8fa9a380c601607ba64540441c970e33304fd4da 100644
--- a/base/memory/discardable_shared_memory_unittest.cc
+++ b/base/memory/discardable_shared_memory_unittest.cc
@@ -44,10 +44,8 @@ TEST(DiscardableSharedMemoryTest, CreateFromHandle) {
bool rv = memory1.CreateAndMap(kDataSize);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
@@ -78,10 +76,8 @@ TEST(DiscardableSharedMemoryTest, LockAndUnlock) {
EXPECT_EQ(DiscardableSharedMemory::SUCCESS, lock_rv);
EXPECT_TRUE(memory1.IsMemoryLocked());
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
@@ -116,10 +112,8 @@ TEST(DiscardableSharedMemoryTest, Purge) {
bool rv = memory1.CreateAndMap(kDataSize);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
@@ -158,10 +152,8 @@ TEST(DiscardableSharedMemoryTest, LastUsed) {
bool rv = memory1.CreateAndMap(kDataSize);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
@@ -226,10 +218,8 @@ TEST(DiscardableSharedMemoryTest, LockShouldAlwaysFailAfterSuccessfulPurge) {
bool rv = memory1.CreateAndMap(kDataSize);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
@@ -255,10 +245,8 @@ TEST(DiscardableSharedMemoryTest, LockAndUnlockRange) {
bool rv = memory1.CreateAndMap(data_size_in_bytes);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(data_size_in_bytes);
@@ -374,10 +362,8 @@ TEST(DiscardableSharedMemoryTest, ZeroFilledPagesAfterPurge) {
bool rv = memory1.CreateAndMap(kDataSize);
ASSERT_TRUE(rv);
- SharedMemoryHandle shared_handle;
- ASSERT_TRUE(
- memory1.ShareToProcess(GetCurrentProcessHandle(), &shared_handle));
- ASSERT_TRUE(SharedMemory::IsHandleValid(shared_handle));
+ SharedMemoryHandle shared_handle = memory1.handle().Duplicate();
+ ASSERT_TRUE(shared_handle.IsValid());
TestDiscardableSharedMemory memory2(shared_handle);
rv = memory2.Map(kDataSize);
« no previous file with comments | « base/memory/discardable_shared_memory.h ('k') | base/memory/shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698