| 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() {
|
|
|