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

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: 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 894de6928ad543e4297de33282d94b5ddc839e93..0aaf4a7b78475fb3f343999d835f68da67d82023 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";
@@ -171,6 +173,7 @@ TEST(HeapDumpWriterTest, BacktraceTypeNameTable) {
AllocationContext ctx = AllocationContext::Empty();
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] }.
@@ -183,6 +186,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] }.
bytes_by_context[ctx] = 30;
@@ -255,16 +259,19 @@ TEST(HeapDumpWriterTest, InsignificantValuesNotDumped) {
AllocationContext ctx = AllocationContext::Empty();
ctx.backtrace.frames[0] = kBrowserMain;
ctx.backtrace.frames[1] = kCreateWidget;
+ ctx.backtrace.frame_count = 2;
// 0.5a KiB in BrowserMain -> CreateWidget itself.
bytes_by_context[ctx] = 512;
// 1 MiB in BrowserMain -> CreateWidget -> GetBitmap.
ctx.backtrace.frames[2] = kGetBitmap;
+ ctx.backtrace.frame_count = 3;
bytes_by_context[ctx] = 1024 * 1024;
// 0.5 KiB in BrowserMain -> CreateWidget -> Initialize.
ctx.backtrace.frames[2] = kInitialize;
+ ctx.backtrace.frame_count = 3;
bytes_by_context[ctx] = 512;
auto sf_deduplicator = WrapUnique(new StackFrameDeduplicator);

Powered by Google App Engine
This is Rietveld 408576698