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

Side by Side Diff: content/common/discardable_shared_memory_heap_unittest.cc

Issue 1306243003: Add support to create memory allocator dump in base::DiscardableMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix html_viewer. Created 5 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/discardable_shared_memory_heap.h" 5 #include "content/common/discardable_shared_memory_heap.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/discardable_shared_memory.h" 8 #include "base/memory/discardable_shared_memory.h"
9 #include "base/process/process_metrics.h" 9 #include "base/process/process_metrics.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 scoped_ptr<DiscardableSharedMemoryHeap::Span> span = 295 scoped_ptr<DiscardableSharedMemoryHeap::Span> span =
296 heap.Grow(memory.Pass(), block_size, next_discardable_shared_memory_id++, 296 heap.Grow(memory.Pass(), block_size, next_discardable_shared_memory_id++,
297 base::Bind(OnDeleted, base::Unretained(&deleted))); 297 base::Bind(OnDeleted, base::Unretained(&deleted)));
298 298
299 heap.MergeIntoFreeLists(span.Pass()); 299 heap.MergeIntoFreeLists(span.Pass());
300 heap.ReleaseFreeMemory(); 300 heap.ReleaseFreeMemory();
301 301
302 EXPECT_TRUE(deleted); 302 EXPECT_TRUE(deleted);
303 } 303 }
304 304
305 TEST(DiscardableSharedMemoryHeapTest, CreateMemoryAllocatorDumpTest) {
306 size_t block_size = base::GetPageSize();
307 DiscardableSharedMemoryHeap heap(block_size);
308 int next_discardable_shared_memory_id = 0;
309
310 scoped_ptr<base::DiscardableSharedMemory> memory(
311 new base::DiscardableSharedMemory);
312 ASSERT_TRUE(memory->CreateAndMap(block_size));
313 scoped_ptr<DiscardableSharedMemoryHeap::Span> span =
314 heap.Grow(memory.Pass(), block_size, next_discardable_shared_memory_id++,
315 base::Bind(NullTask));
316
317 // Check if allocator dump is created when span exists.
318 scoped_ptr<base::trace_event::ProcessMemoryDump> pmd(
319 new base::trace_event::ProcessMemoryDump(nullptr));
320 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test1",
321 pmd.get()));
322
323 // Unlock, Purge and release shared memory.
324 span->shared_memory()->Unlock(0, 0);
325 bool rv = span->shared_memory()->Purge(base::Time::Now());
326 EXPECT_TRUE(rv);
327 heap.ReleasePurgedMemory();
328
329 // Check that allocator dump is created after memory is purged.
330 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test2",
331 pmd.get()));
332 }
333
305 } // namespace 334 } // namespace
306 } // namespace content 335 } // namespace content
OLDNEW
« no previous file with comments | « content/common/discardable_shared_memory_heap.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