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

Unified Diff: content/common/discardable_shared_memory_heap_unittest.cc

Issue 947743002: content: Fix problem with implementation of MergeIntoFreeList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « content/common/discardable_shared_memory_heap.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/discardable_shared_memory_heap_unittest.cc
diff --git a/content/common/discardable_shared_memory_heap_unittest.cc b/content/common/discardable_shared_memory_heap_unittest.cc
index a5e0861c73bf9383af6d29844c8ddbeeadc462c8..a13604f025ba16147d441a2650be37f50e830e01 100644
--- a/content/common/discardable_shared_memory_heap_unittest.cc
+++ b/content/common/discardable_shared_memory_heap_unittest.cc
@@ -105,6 +105,31 @@ TEST_F(DiscardableSharedMemoryHeapTest, SplitAndMerge) {
heap.MergeIntoFreeList(large_span.Pass());
}
+TEST_F(DiscardableSharedMemoryHeapTest, MergeSingleBlockSpan) {
+ size_t block_size = base::GetPageSize();
+ DiscardableSharedMemoryHeap heap(block_size);
+
+ const size_t kBlocks = 6;
+ size_t memory_size = block_size * kBlocks;
+
+ scoped_ptr<base::DiscardableSharedMemory> memory(
+ new base::DiscardableSharedMemory);
+ ASSERT_TRUE(memory->CreateAndMap(memory_size));
+ scoped_ptr<DiscardableSharedMemoryHeap::Span> new_span(
+ heap.Grow(memory.Pass(), memory_size));
+
+ // Split span into two.
+ scoped_ptr<DiscardableSharedMemoryHeap::Span> leftover =
+ heap.Split(new_span.get(), 5);
+ ASSERT_TRUE(leftover);
+
+ // Merge |new_span| into free list.
+ heap.MergeIntoFreeList(new_span.Pass());
+
+ // Merge |leftover| into free list.
+ heap.MergeIntoFreeList(leftover.Pass());
+}
+
TEST_F(DiscardableSharedMemoryHeapTest, Grow) {
size_t block_size = base::GetPageSize();
DiscardableSharedMemoryHeap heap(block_size);
« no previous file with comments | « content/common/discardable_shared_memory_heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698