OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // |capture_enabled| returns true. | 54 // |capture_enabled| returns true. |
55 return subtle::Acquire_Load(&capture_enabled_) != 0; | 55 return subtle::Acquire_Load(&capture_enabled_) != 0; |
56 } | 56 } |
57 | 57 |
58 // Pushes a frame onto the thread-local pseudo stack. | 58 // Pushes a frame onto the thread-local pseudo stack. |
59 static void PushPseudoStackFrame(StackFrame frame); | 59 static void PushPseudoStackFrame(StackFrame frame); |
60 | 60 |
61 // Pops a frame from the thread-local pseudo stack. | 61 // Pops a frame from the thread-local pseudo stack. |
62 static void PopPseudoStackFrame(StackFrame frame); | 62 static void PopPseudoStackFrame(StackFrame frame); |
63 | 63 |
| 64 // Pushes the thread name as the first entry in the pseudo stack. |
| 65 static void SetThreadName(const char* name); |
| 66 |
| 67 // Sets the file name where the current task on thread is posted from. This is |
| 68 // used to categorize theallocations by source path. |
| 69 static void SetCurrentTaskFileName(const char* file_name); |
| 70 |
64 // Returns a snapshot of the current thread-local context. | 71 // Returns a snapshot of the current thread-local context. |
65 static AllocationContext GetContextSnapshot(); | 72 static AllocationContext GetContextSnapshot(); |
66 | 73 |
67 ~AllocationContextTracker(); | 74 ~AllocationContextTracker(); |
68 | 75 |
69 private: | 76 private: |
70 AllocationContextTracker(); | 77 AllocationContextTracker(); |
71 | 78 |
72 static AllocationContextTracker* GetThreadLocalTracker(); | 79 static AllocationContextTracker* GetThreadLocalTracker(); |
73 | 80 |
74 static subtle::Atomic32 capture_enabled_; | 81 static subtle::Atomic32 capture_enabled_; |
75 | 82 |
76 // The pseudo stack where frames are |TRACE_EVENT| names. | 83 // The pseudo stack where frames are |TRACE_EVENT| names. |
77 std::vector<StackFrame> pseudo_stack_; | 84 std::vector<StackFrame> pseudo_stack_; |
78 | 85 |
| 86 // Name of the file from which the current task is posted from. |
| 87 const char* current_task_file_name_; |
| 88 |
79 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); | 89 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); |
80 }; | 90 }; |
81 | 91 |
82 } // namespace trace_event | 92 } // namespace trace_event |
83 } // namespace base | 93 } // namespace base |
84 | 94 |
85 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ | 95 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ |
OLD | NEW |