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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/leak_detector/leak_detector.cc
diff --git a/components/metrics/leak_detector/leak_detector.cc b/components/metrics/leak_detector/leak_detector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0fbd868ccfa2df810e08ea523bd7f82b093f07c6
--- /dev/null
+++ b/components/metrics/leak_detector/leak_detector.cc
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/metrics/leak_detector/leak_detector.h"
+
+#include "content/public/browser/browser_thread.h"
+
+namespace metrics {
+
+LeakDetector::LeakReport::LeakReport() {}
+
+LeakDetector::LeakReport::~LeakReport() {}
+
+LeakDetector::LeakDetector(float sampling_rate,
+ size_t max_call_stack_unwind_depth,
+ uint64_t analysis_interval_bytes,
+ uint32_t size_suspicion_threshold,
+ uint32_t call_stack_suspicion_threshold)
+ : weak_factory_(this) {
+ // TODO(sque): Connect this class to LeakDetectorImpl and base::allocator.
+}
+
+LeakDetector::~LeakDetector() {}
+
+void LeakDetector::AddObserver(Observer* observer) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ observers_.AddObserver(observer);
+}
+
+void LeakDetector::RemoveObserver(Observer* observer) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ observers_.RemoveObserver(observer);
+}
+
+void LeakDetector::NotifyObservers(const std::vector<LeakReport>& reports) {
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&LeakDetector::NotifyObservers, weak_factory_.GetWeakPtr(),
+ reports));
+ return;
+ }
+
+ for (const LeakReport& report : reports) {
+ FOR_EACH_OBSERVER(Observer, observers_, OnLeakFound(report));
+ }
+}
+
+} // namespace metrics
« 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