| 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 <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 detector->last_analysis_alloc_size_ + analysis_interval_bytes) { | 261 detector->last_analysis_alloc_size_ + analysis_interval_bytes) { |
| 262 // Try to maintain regular intervals of size |analysis_interval_bytes_|. | 262 // Try to maintain regular intervals of size |analysis_interval_bytes_|. |
| 263 detector->last_analysis_alloc_size_ = | 263 detector->last_analysis_alloc_size_ = |
| 264 total_alloc_size - total_alloc_size % analysis_interval_bytes; | 264 total_alloc_size - total_alloc_size % analysis_interval_bytes; |
| 265 | 265 |
| 266 InternalVector<InternalLeakReport> leak_reports; | 266 InternalVector<InternalLeakReport> leak_reports; |
| 267 detector->impl_->TestForLeaks(&leak_reports); | 267 detector->impl_->TestForLeaks(&leak_reports); |
| 268 | 268 |
| 269 // Pass leak reports to observers. | 269 // Pass leak reports to observers. |
| 270 std::vector<MemoryLeakReportProto> leak_report_protos; | 270 std::vector<MemoryLeakReportProto> leak_report_protos; |
| 271 leak_report_protos.reserve(leak_reports.size()); |
| 271 std::transform(leak_reports.begin(), leak_reports.end(), | 272 std::transform(leak_reports.begin(), leak_reports.end(), |
| 272 leak_report_protos.begin(), &ConvertLeakReportToProto); | 273 std::back_inserter(leak_report_protos), |
| 274 &ConvertLeakReportToProto); |
| 273 detector->NotifyObservers(leak_report_protos); | 275 detector->NotifyObservers(leak_report_protos); |
| 274 } | 276 } |
| 275 } | 277 } |
| 276 | 278 |
| 277 { | 279 { |
| 278 // The internal memory of |stack| should be freed before setting | 280 // The internal memory of |stack| should be freed before setting |
| 279 // |entered_hook| to false at the end of this function. Free it here by | 281 // |entered_hook| to false at the end of this function. Free it here by |
| 280 // moving the internal memory to a temporary variable that will go out of | 282 // moving the internal memory to a temporary variable that will go out of |
| 281 // scope. | 283 // scope. |
| 282 std::vector<void*> dummy_stack; | 284 std::vector<void*> dummy_stack; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 return; | 328 return; |
| 327 } | 329 } |
| 328 | 330 |
| 329 { | 331 { |
| 330 base::AutoLock lock(observers_lock_); | 332 base::AutoLock lock(observers_lock_); |
| 331 FOR_EACH_OBSERVER(Observer, observers_, OnLeaksFound(reports)); | 333 FOR_EACH_OBSERVER(Observer, observers_, OnLeaksFound(reports)); |
| 332 } | 334 } |
| 333 } | 335 } |
| 334 | 336 |
| 335 } // namespace metrics | 337 } // namespace metrics |
| OLD | NEW |