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

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 new files 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..5665fab1b0e8784f8780dccb971d0033e53c5574
--- /dev/null
+++ b/components/metrics/leak_detector/leak_detector.cc
@@ -0,0 +1,44 @@
+// 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 <algorithm>
+
+namespace metrics {
+
+LeakDetector::LeakReport::LeakReport() {}
+
+LeakDetector::LeakReport::~LeakReport() {}
+
+LeakDetector::LeakDetector(float sampling_rate,
+ int max_stack_depth,
+ uint64_t analysis_interval_bytes,
+ int size_suspicion_threshold,
+ int call_stack_suspicion_threshold) {}
+
+LeakDetector::~LeakDetector() {}
+
+bool LeakDetector::AddObserver(Observer* observer) {
+ observers_.push_back(observer);
+ return true;
Alexei Svitkine (slow) 2016/02/10 20:16:58 If you always return true, why have a return value
Simon Que 2016/02/11 01:45:37 Changing them both to return void, esp in light of
+}
+
+bool LeakDetector::RemoveObserver(Observer* observer) {
+ auto iter = std::find(observers_.begin(), observers_.end(), observer);
+ if (iter == observers_.end())
+ return false;
+ observers_.erase(iter);
+ return true;
+}
+
+void LeakDetector::NotifyObservers(const std::vector<LeakReport>& reports) {
+ for (LeakDetector::Observer* observer : observers_) {
+ for (const LeakReport& report : reports) {
+ observer->OnLeakFound(report);
+ }
+ }
+}
+
+} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698