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 COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ | 5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ |
6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ | 6 #define COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "components/metrics/leak_detector/call_stack_manager.h" | 15 #include "components/metrics/leak_detector/call_stack_manager.h" |
16 #include "components/metrics/leak_detector/custom_allocator.h" | 16 #include "components/metrics/leak_detector/custom_allocator.h" |
17 #include "components/metrics/leak_detector/leak_analyzer.h" | 17 #include "components/metrics/leak_detector/leak_analyzer.h" |
| 18 #include "components/metrics/leak_detector/stl_allocator.h" |
18 | 19 |
19 namespace metrics { | 20 namespace metrics { |
20 namespace leak_detector { | 21 namespace leak_detector { |
21 | 22 |
22 class CallStackTable; | 23 class CallStackTable; |
23 | 24 |
24 // Class that contains the actual leak detection mechanism. | 25 // Class that contains the actual leak detection mechanism. |
25 // Not thread-safe. | 26 // Not thread-safe. |
26 class LeakDetectorImpl { | 27 class LeakDetectorImpl { |
27 public: | 28 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Number of bytes in this allocation. | 98 // Number of bytes in this allocation. |
98 size_t size; | 99 size_t size; |
99 | 100 |
100 // Points to a unique call stack. | 101 // Points to a unique call stack. |
101 const CallStack* call_stack; | 102 const CallStack* call_stack; |
102 }; | 103 }; |
103 | 104 |
104 // Allocator class for allocation entry map. Maps allocated addresses to | 105 // Allocator class for allocation entry map. Maps allocated addresses to |
105 // AllocInfo objects. | 106 // AllocInfo objects. |
106 using AllocationEntryAllocator = | 107 using AllocationEntryAllocator = |
107 STLAllocator<std::pair<const void*, AllocInfo>, CustomAllocator>; | 108 STLAllocator<std::pair<const uintptr_t, AllocInfo>, CustomAllocator>; |
108 | 109 |
109 // Hash class for addresses. | 110 // Hash class for addresses. |
110 struct AddressHash { | 111 struct AddressHash { |
111 size_t operator()(uintptr_t addr) const; | 112 size_t operator()(uintptr_t addr) const; |
112 }; | 113 }; |
113 | 114 |
114 // Returns the offset of |ptr| within the current binary. If it is not in the | 115 // Returns the offset of |ptr| within the current binary. If it is not in the |
115 // current binary, just return |ptr| as an integer. | 116 // current binary, just return |ptr| as an integer. |
116 uintptr_t GetOffset(const void* ptr) const; | 117 uintptr_t GetOffset(const void* ptr) const; |
117 | 118 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // considered a leak suspect. | 155 // considered a leak suspect. |
155 int call_stack_suspicion_threshold_; | 156 int call_stack_suspicion_threshold_; |
156 | 157 |
157 DISALLOW_COPY_AND_ASSIGN(LeakDetectorImpl); | 158 DISALLOW_COPY_AND_ASSIGN(LeakDetectorImpl); |
158 }; | 159 }; |
159 | 160 |
160 } // namespace leak_detector | 161 } // namespace leak_detector |
161 } // namespace metrics | 162 } // namespace metrics |
162 | 163 |
163 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ | 164 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_LEAK_DETECTOR_IMPL_H_ |
OLD | NEW |