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

Side by Side Diff: base/trace_event/heap_profiler_allocation_context_tracker.h

Issue 2272843002: Heap Profiler: Add trace category group names as type names for allocations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_filter
Patch Set: Rebase. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Starts and ends a new ignore scope between which the allocations are 62 // Starts and ends a new ignore scope between which the allocations are
63 // ignored in the heap profiler. A dummy context that short circuits to 63 // ignored in the heap profiler. A dummy context that short circuits to
64 // "tracing_overhead" is returned for these allocations. 64 // "tracing_overhead" is returned for these allocations.
65 void begin_ignore_scope() { ignore_scope_depth_++; } 65 void begin_ignore_scope() { ignore_scope_depth_++; }
66 void end_ignore_scope() { 66 void end_ignore_scope() {
67 if (ignore_scope_depth_) 67 if (ignore_scope_depth_)
68 ignore_scope_depth_--; 68 ignore_scope_depth_--;
69 } 69 }
70 70
71 // Pushes a frame onto the thread-local pseudo stack. 71 // Pushes a frame onto the thread-local pseudo stack.
72 void PushPseudoStackFrame(const char* trace_event_name); 72 void PushPseudoStackFrame(const char* category, const char* trace_event_name);
73 73
74 // Pops a frame from the thread-local pseudo stack. 74 // Pops a frame from the thread-local pseudo stack.
75 void PopPseudoStackFrame(const char* trace_event_name); 75 void PopPseudoStackFrame(const char* category, const char* trace_event_name);
76 76
77 // Push and pop current task's context. A stack is used to support nested 77 // Push and pop current task's context. A stack is used to support nested
78 // tasks and the top of the stack will be used in allocation context. 78 // tasks and the top of the stack will be used in allocation context.
79 void PushCurrentTaskContext(const char* context); 79 void PushCurrentTaskContext(const char* context);
80 void PopCurrentTaskContext(const char* context); 80 void PopCurrentTaskContext(const char* context);
81 81
82 // Returns a snapshot of the current thread-local context. 82 // Returns a snapshot of the current thread-local context.
83 AllocationContext GetContextSnapshot(); 83 AllocationContext GetContextSnapshot();
84 84
85 ~AllocationContextTracker(); 85 ~AllocationContextTracker();
86 86
87 private: 87 private:
88 AllocationContextTracker(); 88 AllocationContextTracker();
89 89
90 static subtle::Atomic32 capture_mode_; 90 static subtle::Atomic32 capture_mode_;
91 91
92 // The pseudo stack where frames are |TRACE_EVENT| names. 92 // The pseudo stack where frames are |TRACE_EVENT| names.
93 std::vector<const char*> pseudo_stack_; 93 std::vector<const char*> pseudo_stack_;
94 94
95 // The thread name is used as the first entry in the pseudo stack. 95 // The thread name is used as the first entry in the pseudo stack.
96 const char* thread_name_; 96 const char* thread_name_;
97 97
98 // Stack of tasks' contexts. Context serves as a different dimension than 98 // Stack of tasks' contexts. Context serves as a different dimension than
99 // pseudo stack to cluster allocations. 99 // pseudo stack to cluster allocations.
100 std::vector<const char*> task_contexts_; 100 std::vector<const char*> task_contexts_;
101 101
102 // If task context was unavailable, then the category names from trace_events
103 // are used to cluster allcoations.
104 std::vector<const char*> trace_categories_;
105
102 uint32_t ignore_scope_depth_; 106 uint32_t ignore_scope_depth_;
103 107
104 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); 108 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker);
105 }; 109 };
106 110
107 } // namespace trace_event 111 } // namespace trace_event
108 } // namespace base 112 } // namespace base
109 113
110 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 114 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698