Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/metrics/leak_detector/leak_detector.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 | |
| 11 namespace metrics { | |
| 12 | |
| 13 LeakDetector::LeakReport::LeakReport() {} | |
| 14 | |
| 15 LeakDetector::LeakReport::~LeakReport() {} | |
| 16 | |
| 17 LeakDetector::LeakDetector(float sampling_rate, | |
| 18 int max_stack_depth, | |
|
jochen (gone - plz use gerrit)
2016/02/24 08:05:22
what does a negative value mean here?
Simon Que
2016/02/24 21:28:34
Changed to size_t.
| |
| 19 uint64_t analysis_interval_bytes, | |
| 20 int size_suspicion_threshold, | |
| 21 int call_stack_suspicion_threshold) | |
|
jochen (gone - plz use gerrit)
2016/02/24 08:05:22
and for those two? what do those values mean anywa
Simon Que
2016/02/24 21:28:34
See comment in header file for meaning.
Changed t
| |
| 22 : weak_factory_(this) {} | |
| 23 | |
| 24 LeakDetector::LeakDetector() : LeakDetector(1.0f, 4, 32 * 1024 * 1024, 4, 4) {} | |
|
jochen (gone - plz use gerrit)
2016/02/24 08:05:22
can you please define constants for these values,
Simon Que
2016/02/24 21:28:35
Done.
| |
| 25 | |
| 26 LeakDetector::~LeakDetector() {} | |
| 27 | |
| 28 void LeakDetector::AddObserver(Observer* observer) { | |
| 29 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 30 observers_.AddObserver(observer); | |
| 31 } | |
| 32 | |
| 33 void LeakDetector::RemoveObserver(Observer* observer) { | |
| 34 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 35 observers_.RemoveObserver(observer); | |
| 36 } | |
| 37 | |
| 38 void LeakDetector::NotifyObservers(const std::vector<LeakReport>& reports) { | |
| 39 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | |
| 40 content::BrowserThread::PostTask( | |
| 41 content::BrowserThread::UI, FROM_HERE, | |
| 42 base::Bind(&LeakDetector::NotifyObservers, weak_factory_.GetWeakPtr(), | |
| 43 reports)); | |
| 44 return; | |
| 45 } | |
| 46 | |
| 47 for (const LeakReport& report : reports) { | |
| 48 FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report)); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 } // namespace metrics | |
| OLD | NEW |