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 using content::BrowserThread; | |
Alexei Svitkine (slow)
2016/02/23 01:23:35
Nit: Just use the content:: prefix in the code dir
Simon Que
2016/02/23 02:38:29
Done.
| |
12 | |
13 namespace metrics { | |
14 | |
15 const base::Feature kEnableRuntimeMemoryLeakDetector = { | |
Alexei Svitkine (slow)
2016/02/23 01:23:35
Nit: No =
Simon Que
2016/02/23 02:38:29
Done.
| |
16 "enable-runtime-memory-leak-detector", base::FEATURE_DISABLED_BY_DEFAULT}; | |
Alexei Svitkine (slow)
2016/02/23 01:23:35
Nit: "RuntimeMemoryLeakDetector"
Given you're not
Simon Que
2016/02/23 02:38:29
Done.
| |
17 | |
18 LeakDetector::LeakReport::LeakReport() {} | |
19 | |
20 LeakDetector::LeakReport::~LeakReport() {} | |
21 | |
22 LeakDetector::LeakDetector(float sampling_rate, | |
23 int max_stack_depth, | |
24 uint64_t analysis_interval_bytes, | |
25 int size_suspicion_threshold, | |
26 int call_stack_suspicion_threshold) | |
27 : weak_factory_(this) {} | |
28 | |
29 LeakDetector::LeakDetector() : LeakDetector(1.0f, 4, 32 * 1024 * 1024, 4, 4) {} | |
30 | |
31 LeakDetector::~LeakDetector() {} | |
32 | |
33 void LeakDetector::AddObserver(Observer* observer) { | |
34 DCHECK(thread_checker_.CalledOnValidThread()); | |
35 observers_.AddObserver(observer); | |
36 } | |
37 | |
38 void LeakDetector::RemoveObserver(Observer* observer) { | |
39 DCHECK(thread_checker_.CalledOnValidThread()); | |
40 observers_.RemoveObserver(observer); | |
41 } | |
42 | |
43 void LeakDetector::NotifyObservers(const std::vector<LeakReport>& reports) { | |
44 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
45 BrowserThread::PostTask(BrowserThread::UI, | |
46 FROM_HERE, | |
47 base::Bind(&LeakDetector::NotifyObservers, | |
48 weak_factory_.GetWeakPtr(), | |
49 reports)); | |
50 return; | |
51 } | |
52 | |
53 for (const LeakReport& report : reports) { | |
54 FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report)); | |
55 } | |
56 } | |
57 | |
58 } // namespace metrics | |
OLD | NEW |