Index: chrome/browser/metrics/leak_detector_controller.h |
diff --git a/chrome/browser/metrics/leak_detector_controller.h b/chrome/browser/metrics/leak_detector_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..32626fbb6252606562169ad48d6cdeb44c813234 |
--- /dev/null |
+++ b/chrome/browser/metrics/leak_detector_controller.h |
@@ -0,0 +1,43 @@ |
+// 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. |
+ |
+#ifndef CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |
+#define CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |
+ |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "components/metrics/leak_detector/leak_detector.h" |
+#include "components/metrics/proto/memory_leak_report.pb.h" |
+ |
+namespace metrics { |
+ |
+// This class initializes the LeakDetector on the browser process and registers |
+// itself to be notified of leak reports. |
+class LeakDetectorController : public LeakDetector::Observer { |
+ public: |
+ LeakDetectorController(); |
+ ~LeakDetectorController(); |
+ |
+ // Stores a new leak report in |stored_reports_|. |
Alexei Svitkine (slow)
2016/02/12 16:17:42
This comment should just be:
// LeakDetector::Obs
Simon Que
2016/02/12 19:00:07
Will make this change once I know what to do regar
Simon Que
2016/02/17 20:49:33
Done.
|
+ void OnLeakFound(const LeakDetector::LeakReport& report) override; |
Alexei Svitkine (slow)
2016/02/12 16:17:42
Move this to private section.
Simon Que
2016/02/12 19:00:07
What about the unit test? It calls this func. How
Alexei Svitkine (slow)
2016/02/17 16:06:30
Derived class that exposes these functions SGTM.
Simon Que
2016/02/17 20:49:33
Done.
|
+ |
+ // Retrieves all reports in |stored_reports_|, moving them to |*reports|. |
+ // |stored_reports_| is empty afterwards. |
+ void GetLeakReports(std::vector<MemoryLeakReportProto>* reports); |
+ |
+ private: |
+ // Leak detector interface object. |
+ LeakDetector detector_; |
+ |
+ // All leak reports received through OnLeakFound() are stored in protobuf |
+ // format. |
+ std::vector<MemoryLeakReportProto> stored_reports_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LeakDetectorController); |
+}; |
+ |
+} // namespace metrics |
+ |
+#endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |