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

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

Issue 1891543003: [tracing] Turn StackFrame into struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add "the ones closer to main()" Created 4 years, 8 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Returns the thread-local instance, creating one if necessary. Returns 46 // Returns the thread-local instance, creating one if necessary. Returns
47 // always a valid instance, unless it is called re-entrantly, in which case 47 // always a valid instance, unless it is called re-entrantly, in which case
48 // returns nullptr in the nested calls. 48 // returns nullptr in the nested calls.
49 static AllocationContextTracker* GetInstanceForCurrentThread(); 49 static AllocationContextTracker* GetInstanceForCurrentThread();
50 50
51 // Set the thread name in the AllocationContextTracker of the current thread 51 // Set the thread name in the AllocationContextTracker of the current thread
52 // if capture is enabled. 52 // if capture is enabled.
53 static void SetCurrentThreadName(const char* name); 53 static void SetCurrentThreadName(const char* name);
54 54
55 // Pushes a frame onto the thread-local pseudo stack. 55 // Pushes a frame onto the thread-local pseudo stack.
56 void PushPseudoStackFrame(StackFrame frame); 56 void PushPseudoStackFrame(const char* trace_event_name);
57 57
58 // Pops a frame from the thread-local pseudo stack. 58 // Pops a frame from the thread-local pseudo stack.
59 void PopPseudoStackFrame(StackFrame frame); 59 void PopPseudoStackFrame(const char* trace_event_name);
60 60
61 // Push and pop current task's context. A stack is used to support nested 61 // Push and pop current task's context. A stack is used to support nested
62 // tasks and the top of the stack will be used in allocation context. 62 // tasks and the top of the stack will be used in allocation context.
63 void PushCurrentTaskContext(const char* context); 63 void PushCurrentTaskContext(const char* context);
64 void PopCurrentTaskContext(const char* context); 64 void PopCurrentTaskContext(const char* context);
65 65
66 // Returns a snapshot of the current thread-local context. 66 // Returns a snapshot of the current thread-local context.
67 AllocationContext GetContextSnapshot(); 67 AllocationContext GetContextSnapshot();
68 68
69 ~AllocationContextTracker(); 69 ~AllocationContextTracker();
70 70
71 private: 71 private:
72 AllocationContextTracker(); 72 AllocationContextTracker();
73 73
74 static subtle::Atomic32 capture_enabled_; 74 static subtle::Atomic32 capture_enabled_;
75 75
76 // The pseudo stack where frames are |TRACE_EVENT| names. 76 // The pseudo stack where frames are |TRACE_EVENT| names.
77 std::vector<StackFrame> pseudo_stack_; 77 std::vector<const char*> pseudo_stack_;
78 78
79 // The thread name is used as the first entry in the pseudo stack. 79 // The thread name is used as the first entry in the pseudo stack.
80 const char* thread_name_; 80 const char* thread_name_;
81 81
82 // Stack of tasks' contexts. Context serves as a different dimension than 82 // Stack of tasks' contexts. Context serves as a different dimension than
83 // pseudo stack to cluster allocations. 83 // pseudo stack to cluster allocations.
84 std::vector<const char*> task_contexts_; 84 std::vector<const char*> task_contexts_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); 86 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker);
87 }; 87 };
88 88
89 } // namespace trace_event 89 } // namespace trace_event
90 } // namespace base 90 } // namespace base
91 91
92 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 92 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_allocation_context.cc ('k') | base/trace_event/heap_profiler_allocation_context_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698