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

Unified Diff: base/trace_event/heap_profiler_heap_dump_writer_unittest.cc

Issue 1891543003: [tracing] Turn StackFrame into struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add "the ones closer to main()" Created 4 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
Index: base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
diff --git a/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc b/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
index 8faa5cf2f91a1be164bf5973f6b17c0466766f80..e7850a142cb735fe6700a1b54db94449185ddb41 100644
--- a/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
+++ b/base/trace_event/heap_profiler_heap_dump_writer_unittest.cc
@@ -22,13 +22,15 @@
namespace {
+using base::trace_event::StackFrame;
+
// Define all strings once, because the deduplicator requires pointer equality,
// and string interning is unreliable.
-const char kBrowserMain[] = "BrowserMain";
-const char kRendererMain[] = "RendererMain";
-const char kCreateWidget[] = "CreateWidget";
-const char kInitialize[] = "Initialize";
-const char kGetBitmap[] = "GetBitmap";
+StackFrame kBrowserMain = StackFrame::FromTraceEventName("BrowserMain");
+StackFrame kRendererMain = StackFrame::FromTraceEventName("RendererMain");
+StackFrame kCreateWidget = StackFrame::FromTraceEventName("CreateWidget");
+StackFrame kInitialize = StackFrame::FromTraceEventName("Initialize");
+StackFrame kGetBitmap = StackFrame::FromTraceEventName("GetBitmap");
const char kInt[] = "int";
const char kBool[] = "bool";
@@ -178,9 +180,10 @@ TEST(HeapDumpWriterTest, SizeAndCountAreHexadecimal) {
TEST(HeapDumpWriterTest, BacktraceTypeNameTable) {
hash_map<AllocationContext, AllocationMetrics> metrics_by_context;
- AllocationContext ctx = AllocationContext::Empty();
+ AllocationContext ctx;
ctx.backtrace.frames[0] = kBrowserMain;
ctx.backtrace.frames[1] = kCreateWidget;
+ ctx.backtrace.frame_count = 2;
ctx.type_name = kInt;
// 10 bytes with context { type: int, bt: [BrowserMain, CreateWidget] }.
@@ -193,6 +196,7 @@ TEST(HeapDumpWriterTest, BacktraceTypeNameTable) {
ctx.backtrace.frames[0] = kRendererMain;
ctx.backtrace.frames[1] = kInitialize;
+ ctx.backtrace.frame_count = 2;
// 30 bytes with context { type: bool, bt: [RendererMain, Initialize] }.
metrics_by_context[ctx] = {30, 30};
@@ -267,19 +271,22 @@ TEST(HeapDumpWriterTest, BacktraceTypeNameTable) {
TEST(HeapDumpWriterTest, InsignificantValuesNotDumped) {
hash_map<AllocationContext, AllocationMetrics> metrics_by_context;
- AllocationContext ctx = AllocationContext::Empty();
+ AllocationContext ctx;
ctx.backtrace.frames[0] = kBrowserMain;
ctx.backtrace.frames[1] = kCreateWidget;
+ ctx.backtrace.frame_count = 2;
// 0.5 KiB and 1 chunk in BrowserMain -> CreateWidget itself.
metrics_by_context[ctx] = {512, 1};
// 1 MiB and 1 chunk in BrowserMain -> CreateWidget -> GetBitmap.
ctx.backtrace.frames[2] = kGetBitmap;
+ ctx.backtrace.frame_count = 3;
metrics_by_context[ctx] = {1024 * 1024, 1};
// 0.5 KiB and 1 chunk in BrowserMain -> CreateWidget -> Initialize.
ctx.backtrace.frames[2] = kInitialize;
+ ctx.backtrace.frame_count = 3;
metrics_by_context[ctx] = {512, 1};
auto sf_deduplicator = WrapUnique(new StackFrameDeduplicator);
« no previous file with comments | « base/trace_event/heap_profiler_heap_dump_writer.cc ('k') | base/trace_event/heap_profiler_stack_frame_deduplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698