| Index: base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.cc b/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| index 8a4dbc7d8ca8f22f698ed0de63c4b9a408dd57e1..da00df18d7ea0556404f2eac5f46a6616c7150ec 100644
|
| --- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| +++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| @@ -32,9 +32,11 @@ void DestructAllocationContextTracker(void* alloc_ctx_tracker) {
|
|
|
| } // namespace
|
|
|
| -AllocationContextTracker::AllocationContextTracker() {
|
| +AllocationContextTracker::AllocationContextTracker()
|
| + : current_task_file_name_(nullptr) {
|
| pseudo_stack_.reserve(kMaxStackDepth);
|
| }
|
| +
|
| AllocationContextTracker::~AllocationContextTracker() {}
|
|
|
| // static
|
| @@ -113,6 +115,22 @@ void AllocationContextTracker::PopPseudoStackFrame(StackFrame frame) {
|
| }
|
|
|
| // static
|
| +void AllocationContextTracker::SetThreadName(const char* name) {
|
| + auto tracker = AllocationContextTracker::GetThreadLocalTracker();
|
| +
|
| + // The thread name is added as the first entry in the psuedo stack. This is
|
| + // not removed until the tls is destroyed when thread dies.
|
| + tracker->pseudo_stack_.insert(tracker->pseudo_stack_.begin(),
|
| + static_cast<StackFrame>(name));
|
| +}
|
| +
|
| +// static
|
| +void AllocationContextTracker::SetCurrentTaskFileName(const char* file_name) {
|
| + AllocationContextTracker* tracker = GetThreadLocalTracker();
|
| + tracker->current_task_file_name_ = file_name;
|
| +}
|
| +
|
| +// static
|
| AllocationContext AllocationContextTracker::GetContextSnapshot() {
|
| AllocationContextTracker* tracker = GetThreadLocalTracker();
|
| AllocationContext ctx;
|
| @@ -133,7 +151,10 @@ AllocationContext AllocationContextTracker::GetContextSnapshot() {
|
| std::fill(dst, dst_end, nullptr);
|
| }
|
|
|
| - ctx.type_name = nullptr;
|
| + // Set the default type name to file name where the task was posted from.
|
| + // TODO(ssid): Fix crbug.com/594803 to add file name as 3rd dimension
|
| + // (component name) in the heap profiler and not piggy back on the type name.
|
| + ctx.type_name = tracker->current_task_file_name_;
|
|
|
| return ctx;
|
| }
|
|
|