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

Unified Diff: base/trace_event/heap_profiler.h

Issue 1950313005: [tracing] Move and rename TRACE_EVENT_API_TASK_EXECUTION_EVENT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_missing_task
Patch Set: fix unittest. Created 4 years, 7 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.h
diff --git a/base/trace_event/heap_profiler.h b/base/trace_event/heap_profiler.h
index 3ac16cd53b0d5ae2270aa5d1cb41152842bd58a9..cf5752462707d7a14aaf37271b7065f9efc9c6ba 100644
--- a/base/trace_event/heap_profiler.h
+++ b/base/trace_event/heap_profiler.h
@@ -21,6 +21,10 @@
#define INTERNAL_HEAP_PROFILER_UID(name_prefix) \
INTERNAL_HEAP_PROFILER_UID2(name_prefix, __LINE__)
+// Scoped tracker for task execution context in the heap profiler.
+#define TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION \
+ trace_event_internal::HeapProfilerScopedTaskExecutionTracker
+
// A scoped ignore event used to tell heap profiler to ignore all the
// allocations in the scope. It is useful to exclude allocations made for
// tracing from the heap profiler dumps.
@@ -30,6 +34,34 @@
namespace trace_event_internal {
+// HeapProfilerScopedTaskExecutionTracker records the current task's context in
+// the heap profiler.
+class HeapProfilerScopedTaskExecutionTracker {
+ public:
+ inline explicit HeapProfilerScopedTaskExecutionTracker(
+ const char* task_context)
+ : context_(task_context) {
+ using base::trace_event::AllocationContextTracker;
+ if (UNLIKELY(AllocationContextTracker::capture_mode() !=
+ AllocationContextTracker::CaptureMode::DISABLED)) {
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->PushCurrentTaskContext(context_);
+ }
+ }
+
+ inline ~HeapProfilerScopedTaskExecutionTracker() {
+ using base::trace_event::AllocationContextTracker;
+ if (UNLIKELY(AllocationContextTracker::capture_mode() !=
+ AllocationContextTracker::CaptureMode::DISABLED)) {
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->PopCurrentTaskContext(context_);
+ }
+ }
+
+ private:
+ const char* context_;
+};
+
class BASE_EXPORT HeapProfilerScopedIgnore {
public:
inline HeapProfilerScopedIgnore() {
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698