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