Chromium Code Reviews| 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..f26465a2c71c7a586d0f28d667c3382d5b98b49e 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,24 @@ void AllocationContextTracker::PopPseudoStackFrame(StackFrame frame) { |
| } |
| // static |
| +void AllocationContextTracker::SetThreadName(const char* name) { |
| + auto tracker = AllocationContextTracker::GetThreadLocalTracker(); |
| + CHECK(tracker); |
|
Primiano Tucci (use gerrit)
2016/03/15 16:44:33
NO need for this CHECK. If tracker is nullptr, thi
ssid
2016/03/17 00:11:47
Done.
|
| + |
| + // 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(); |
| + CHECK(tracker); |
| + tracker->current_task_file_name_ = file_name; |
| +} |
| + |
| +// static |
| AllocationContext AllocationContextTracker::GetContextSnapshot() { |
| AllocationContextTracker* tracker = GetThreadLocalTracker(); |
| AllocationContext ctx; |
| @@ -133,7 +153,9 @@ 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. |
|
Primiano Tucci (use gerrit)
2016/03/15 16:44:33
Can you add a TODO: this should be a 3rd dimension
ssid
2016/03/17 00:11:47
Done.
|
| + // Trace viewer uses the file name to categorize allocation by file name. |
| + ctx.type_name = tracker->current_task_file_name_; |
| return ctx; |
| } |