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_H_ | 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <functional> |
| 12 |
11 #include "base/base_export.h" | 13 #include "base/base_export.h" |
12 #include "base/containers/hash_tables.h" | |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 namespace trace_event { | 16 namespace trace_event { |
16 | 17 |
17 // When heap profiling is enabled, tracing keeps track of the allocation | 18 // When heap profiling is enabled, tracing keeps track of the allocation |
18 // context for each allocation intercepted. It is generated by the | 19 // context for each allocation intercepted. It is generated by the |
19 // |AllocationContextTracker| which keeps stacks of context in TLS. | 20 // |AllocationContextTracker| which keeps stacks of context in TLS. |
20 // The tracker is initialized lazily. | 21 // The tracker is initialized lazily. |
21 | 22 |
22 // The backtrace in the allocation context is a snapshot of the stack. For now, | 23 // The backtrace in the allocation context is a snapshot of the stack. For now, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 // Struct to store the size and count of the allocations. | 104 // Struct to store the size and count of the allocations. |
104 struct AllocationMetrics { | 105 struct AllocationMetrics { |
105 size_t size; | 106 size_t size; |
106 size_t count; | 107 size_t count; |
107 }; | 108 }; |
108 | 109 |
109 } // namespace trace_event | 110 } // namespace trace_event |
110 } // namespace base | 111 } // namespace base |
111 | 112 |
112 namespace BASE_HASH_NAMESPACE { | 113 namespace std { |
113 | 114 |
114 template <> | 115 template <> |
115 struct BASE_EXPORT hash<base::trace_event::StackFrame> { | 116 struct BASE_EXPORT hash<base::trace_event::StackFrame> { |
116 size_t operator()(const base::trace_event::StackFrame& frame) const; | 117 size_t operator()(const base::trace_event::StackFrame& frame) const; |
117 }; | 118 }; |
118 | 119 |
119 template <> | 120 template <> |
120 struct BASE_EXPORT hash<base::trace_event::Backtrace> { | 121 struct BASE_EXPORT hash<base::trace_event::Backtrace> { |
121 size_t operator()(const base::trace_event::Backtrace& backtrace) const; | 122 size_t operator()(const base::trace_event::Backtrace& backtrace) const; |
122 }; | 123 }; |
123 | 124 |
124 template <> | 125 template <> |
125 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { | 126 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { |
126 size_t operator()(const base::trace_event::AllocationContext& context) const; | 127 size_t operator()(const base::trace_event::AllocationContext& context) const; |
127 }; | 128 }; |
128 | 129 |
129 } // BASE_HASH_NAMESPACE | 130 } // namespace std |
130 | 131 |
131 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 132 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
OLD | NEW |