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

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

Issue 2006943003: [tracing] Sanitize process memory dumps for background mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@whitelist_mdp
Patch Set: Fix stripping. Created 4 years, 6 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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 std::unique_ptr<base::DiscardableSharedMemory> memory( 313 std::unique_ptr<base::DiscardableSharedMemory> memory(
314 new base::DiscardableSharedMemory); 314 new base::DiscardableSharedMemory);
315 ASSERT_TRUE(memory->CreateAndMap(block_size)); 315 ASSERT_TRUE(memory->CreateAndMap(block_size));
316 std::unique_ptr<DiscardableSharedMemoryHeap::Span> span = 316 std::unique_ptr<DiscardableSharedMemoryHeap::Span> span =
317 heap.Grow(std::move(memory), block_size, 317 heap.Grow(std::move(memory), block_size,
318 next_discardable_shared_memory_id++, base::Bind(NullTask)); 318 next_discardable_shared_memory_id++, base::Bind(NullTask));
319 319
320 // Check if allocator dump is created when span exists. 320 // Check if allocator dump is created when span exists.
321 std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd( 321 std::unique_ptr<base::trace_event::ProcessMemoryDump> pmd(
322 new base::trace_event::ProcessMemoryDump(nullptr)); 322 new base::trace_event::ProcessMemoryDump(
323 nullptr, {base::trace_event::MemoryDumpLevelOfDetail::DETAILED}));
323 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test1", 324 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test1",
324 pmd.get())); 325 pmd.get()));
325 326
326 // Unlock, Purge and release shared memory. 327 // Unlock, Purge and release shared memory.
327 span->shared_memory()->Unlock(0, 0); 328 span->shared_memory()->Unlock(0, 0);
328 bool rv = span->shared_memory()->Purge(base::Time::Now()); 329 bool rv = span->shared_memory()->Purge(base::Time::Now());
329 EXPECT_TRUE(rv); 330 EXPECT_TRUE(rv);
330 heap.ReleasePurgedMemory(); 331 heap.ReleasePurgedMemory();
331 332
332 // Check that allocator dump is created after memory is purged. 333 // Check that allocator dump is created after memory is purged.
333 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test2", 334 EXPECT_TRUE(heap.CreateMemoryAllocatorDump(span.get(), "discardable/test2",
334 pmd.get())); 335 pmd.get()));
335 } 336 }
336 337
337 } // namespace 338 } // namespace
338 } // namespace content 339 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698