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

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

Issue 1391933004: [Tracing] Add hook to PartitionAlloc for heap profiling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address primiano comments Created 5 years, 2 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_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_
6 #define BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_ 6 #define BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // higher than what can be stored here, the bottom frames are stored. Based 79 // higher than what can be stored here, the bottom frames are stored. Based
80 // on the data above, a depth of 12 captures the full stack in the vast 80 // on the data above, a depth of 12 captures the full stack in the vast
81 // majority of the cases. 81 // majority of the cases.
82 StackFrame frames[12]; 82 StackFrame frames[12];
83 } backtrace; 83 } backtrace;
84 84
85 // There is room for two arbitrary context fields, which can be set by the 85 // There is room for two arbitrary context fields, which can be set by the
86 // |TRACE_ALLOCATION_CONTEXT| macro. A nullptr key indicates that the field is 86 // |TRACE_ALLOCATION_CONTEXT| macro. A nullptr key indicates that the field is
87 // unused. 87 // unused.
88 std::pair<const char*, const char*> fields[2]; 88 std::pair<const char*, const char*> fields[2];
89
90 // Returns an |AllocationContext| with empty backtrace and no fields.
91 static AllocationContext GetEmpty();
89 }; 92 };
90 93
91 // The allocation context tracker keeps track of thread-local context for heap 94 // The allocation context tracker keeps track of thread-local context for heap
92 // profiling. It includes a pseudo stack of trace events, and it might contain 95 // profiling. It includes a pseudo stack of trace events, and it might contain
93 // arbitrary (key, value) context. On every allocation the tracker provides a 96 // arbitrary (key, value) context. On every allocation the tracker provides a
94 // snapshot of its context in the form of an |AllocationContext| that is to be 97 // snapshot of its context in the form of an |AllocationContext| that is to be
95 // stored together with the allocation details. 98 // stored together with the allocation details.
96 class BASE_EXPORT AllocationContextTracker { 99 class BASE_EXPORT AllocationContextTracker {
97 public: 100 public:
98 // Globally enables capturing allocation context. 101 // Globally enables capturing allocation context.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // A dictionary of arbitrary context. 149 // A dictionary of arbitrary context.
147 SmallMap<std::map<const char*, const char*>> context_; 150 SmallMap<std::map<const char*, const char*>> context_;
148 151
149 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); 152 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker);
150 }; 153 };
151 154
152 } // namespace trace_event 155 } // namespace trace_event
153 } // namespace base 156 } // namespace base
154 157
155 #endif // BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_ 158 #endif // BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698