| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "components/metrics/leak_detector/leak_detector.h" | 5 #include "components/metrics/leak_detector/leak_detector.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // The effective max value of |alloc_size| is thus half its nominal max value. | 148 // The effective max value of |alloc_size| is thus half its nominal max value. |
| 149 uintptr_t ptr_value = | 149 uintptr_t ptr_value = |
| 150 (hook_data.entered_hook ? 1 : 0) | (hook_data.alloc_size << 1); | 150 (hook_data.entered_hook ? 1 : 0) | (hook_data.alloc_size << 1); |
| 151 g_hook_data_tls.Get().Set(reinterpret_cast<void*>(ptr_value)); | 151 g_hook_data_tls.Get().Set(reinterpret_cast<void*>(ptr_value)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace | 154 } // namespace |
| 155 | 155 |
| 156 LeakDetector::LeakReport::LeakReport() {} | 156 LeakDetector::LeakReport::LeakReport() {} |
| 157 | 157 |
| 158 LeakDetector::LeakReport::LeakReport(const LeakReport& other) = default; |
| 159 |
| 158 LeakDetector::LeakReport::~LeakReport() {} | 160 LeakDetector::LeakReport::~LeakReport() {} |
| 159 | 161 |
| 160 // static | 162 // static |
| 161 LeakDetector* LeakDetector::GetInstance() { | 163 LeakDetector* LeakDetector::GetInstance() { |
| 162 return g_instance.Pointer(); | 164 return g_instance.Pointer(); |
| 163 } | 165 } |
| 164 | 166 |
| 165 void LeakDetector::Init(float sampling_rate, | 167 void LeakDetector::Init(float sampling_rate, |
| 166 size_t max_call_stack_unwind_depth, | 168 size_t max_call_stack_unwind_depth, |
| 167 uint64_t analysis_interval_bytes, | 169 uint64_t analysis_interval_bytes, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return; | 331 return; |
| 330 } | 332 } |
| 331 | 333 |
| 332 for (const LeakReport& report : reports) { | 334 for (const LeakReport& report : reports) { |
| 333 base::AutoLock lock(observers_lock_); | 335 base::AutoLock lock(observers_lock_); |
| 334 FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report)); | 336 FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report)); |
| 335 } | 337 } |
| 336 } | 338 } |
| 337 | 339 |
| 338 } // namespace metrics | 340 } // namespace metrics |
| OLD | NEW |