| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 inline bool LeakDetector::ShouldSample(const void* ptr) const { | 332 inline bool LeakDetector::ShouldSample(const void* ptr) const { |
| 333 return PointerToHash(ptr) < sampling_factor_; | 333 return PointerToHash(ptr) < sampling_factor_; |
| 334 } | 334 } |
| 335 | 335 |
| 336 void LeakDetector::NotifyObservers( | 336 void LeakDetector::NotifyObservers( |
| 337 const std::vector<MemoryLeakReportProto>& reports) { | 337 const std::vector<MemoryLeakReportProto>& reports) { |
| 338 if (reports.empty()) | 338 if (reports.empty()) |
| 339 return; | 339 return; |
| 340 | 340 |
| 341 if (!task_runner_->RunsTasksOnCurrentThread()) { | 341 if (!task_runner_->RunsTasksInCurrentSequence()) { |
| 342 task_runner_->PostTask(FROM_HERE, | 342 task_runner_->PostTask(FROM_HERE, |
| 343 base::Bind(&LeakDetector::NotifyObservers, | 343 base::Bind(&LeakDetector::NotifyObservers, |
| 344 base::Unretained(this), reports)); | 344 base::Unretained(this), reports)); |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 | 347 |
| 348 { | 348 { |
| 349 base::AutoLock lock(observers_lock_); | 349 base::AutoLock lock(observers_lock_); |
| 350 for (Observer& observer : observers_) | 350 for (Observer& observer : observers_) |
| 351 observer.OnLeaksFound(reports); | 351 observer.OnLeaksFound(reports); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace metrics | 355 } // namespace metrics |
| OLD | NEW |