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

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: 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 dd587e5e4c72ea40fbfb2bb353dd0052b8688b34..694579cb660a72f27824527c88ccdf1955dde54e 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 HEAP_PROFILER_API_SCOPED_TASK_EXECUTION_EVENT \
+ trace_event_internal::HeapProfilerScopedTaskExecutionEvent
+
// 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,31 @@
namespace trace_event_internal {
+// HeapProfilerScopedTaskExecutionEvent records the current task's context in
+// the heap profiler.
+class HeapProfilerScopedTaskExecutionEvent {
+ public:
+ inline explicit HeapProfilerScopedTaskExecutionEvent(const char* task_context)
+ : context_(task_context) {
+ if (UNLIKELY(
+ base::trace_event::AllocationContextTracker::capture_enabled())) {
+ base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
+ ->PushCurrentTaskContext(context_);
+ }
+ }
+
+ inline ~HeapProfilerScopedTaskExecutionEvent() {
+ if (UNLIKELY(
+ base::trace_event::AllocationContextTracker::capture_enabled())) {
+ base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread()
+ ->PopCurrentTaskContext(context_);
+ }
+ }
+
+ private:
+ const char* context_;
+};
+
class BASE_EXPORT HeapProfilerScopedIgnore {
public:
inline HeapProfilerScopedIgnore() {

Powered by Google App Engine
This is Rietveld 408576698