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

Unified Diff: base/memory/discardable_shared_memory_unittest.cc

Issue 1146103002: content: Close in-process discardable memory segments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment typo Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/discardable_shared_memory.cc ('k') | content/common/host_discardable_shared_memory_manager.cc » ('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 ae7235d108cd69e2effdb732a41d0bd2d5e05457..91b0b68523aed4d24a5425ea0f96fdb6cf96c04b 100644
--- a/base/memory/discardable_shared_memory_unittest.cc
+++ b/base/memory/discardable_shared_memory_unittest.cc
@@ -306,11 +306,34 @@ TEST(DiscardableSharedMemoryTest, MappedSize) {
EXPECT_LE(kDataSize, memory.mapped_size());
- // Mapped size should be 0 after memory segment has been closed.
- memory.Close();
+ // Mapped size should be 0 after memory segment has been unmapped.
+ rv = memory.Unmap();
+ EXPECT_TRUE(rv);
EXPECT_EQ(0u, memory.mapped_size());
}
+TEST(DiscardableSharedMemoryTest, Close) {
+ const uint32 kDataSize = 1024;
+
+ TestDiscardableSharedMemory memory;
+ bool rv = memory.CreateAndMap(kDataSize);
+ ASSERT_TRUE(rv);
+
+ // Mapped size should be unchanged after memory segment has been closed.
+ memory.Close();
+ EXPECT_LE(kDataSize, memory.mapped_size());
+
+ // Memory is initially locked. Unlock it.
+ memory.SetNow(Time::FromDoubleT(1));
+ memory.Unlock(0, 0);
+
+ // Lock and unlock memory.
+ auto lock_rv = memory.Lock(0, 0);
+ EXPECT_EQ(DiscardableSharedMemory::SUCCESS, lock_rv);
+ memory.SetNow(Time::FromDoubleT(2));
+ memory.Unlock(0, 0);
+}
+
#if defined(DISCARDABLE_SHARED_MEMORY_SHRINKING)
TEST(DiscardableSharedMemoryTest, Shrink) {
const uint32 kDataSize = 1024;
« no previous file with comments | « base/memory/discardable_shared_memory.cc ('k') | content/common/host_discardable_shared_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698