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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc

Issue 1851233002: Reland of [tracing] Adding task information to heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove event from sequenced_worker_pool.cc Created 4 years, 9 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_allocation_context_tracker_unittest.cc
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
index 6349ec0c007e7b5317bcbe6417d8e62a3b5f0426..05c60c722c317cca7bf6e52453a5faba1d7b1903 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
@@ -7,6 +7,7 @@
#include <iterator>
#include "base/memory/ref_counted.h"
+#include "base/pending_task.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
#include "base/trace_event/trace_event.h"
@@ -251,5 +252,31 @@ TEST_F(AllocationContextTrackerTest, SetCurrentThreadName) {
ASSERT_EQ(kCupcake, ctx2.backtrace.frames[1]);
}
+TEST_F(AllocationContextTrackerTest, TrackTaskContext) {
+ const char kContext1[] = "context1";
+ const char kContext2[] = "context2";
+ {
+ // The context from the scoped task event should be used as type name.
+ TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT event1(kContext1);
+ AllocationContext ctx1 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ(kContext1, ctx1.type_name);
+
+ // In case of nested events, the last event's context should be used.
+ TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT event2(kContext2);
+ AllocationContext ctx2 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ(kContext2, ctx2.type_name);
+ }
+
+ // Type should be nullptr without task event.
+ AllocationContext ctx =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_FALSE(ctx.type_name);
+}
+
} // namespace trace_event
} // namespace base
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context_tracker.cc ('k') | base/trace_event/heap_profiler_type_name_deduplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698