Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: components/metrics/leak_detector/leak_detector.cc

Issue 1681263003: metrics: Add leak detector controller in Chrome OS metrics system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add content/public/browser to GN deps Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "content/public/browser/browser_thread.h"
8
9 namespace metrics {
10
11 LeakDetector::LeakReport::LeakReport() {}
12
13 LeakDetector::LeakReport::~LeakReport() {}
14
15 LeakDetector::LeakDetector(float sampling_rate,
16 size_t max_call_stack_unwind_depth,
17 uint64_t analysis_interval_bytes,
18 uint32_t size_suspicion_threshold,
19 uint32_t call_stack_suspicion_threshold)
20 : weak_factory_(this) {
21 // TODO(sque): Connect this class to LeakDetectorImpl and base::allocator.
22 }
23
24 LeakDetector::~LeakDetector() {}
25
26 void LeakDetector::AddObserver(Observer* observer) {
27 DCHECK(thread_checker_.CalledOnValidThread());
28 observers_.AddObserver(observer);
29 }
30
31 void LeakDetector::RemoveObserver(Observer* observer) {
32 DCHECK(thread_checker_.CalledOnValidThread());
33 observers_.RemoveObserver(observer);
34 }
35
36 void LeakDetector::NotifyObservers(const std::vector<LeakReport>& reports) {
37 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
38 content::BrowserThread::PostTask(
39 content::BrowserThread::UI, FROM_HERE,
40 base::Bind(&LeakDetector::NotifyObservers, weak_factory_.GetWeakPtr(),
41 reports));
42 return;
43 }
44
45 for (const LeakReport& report : reports) {
46 FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report));
47 }
48 }
49
50 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/leak_detector/leak_detector.h ('k') | components/metrics/leak_detector/leak_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698