Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "chrome/browser/metrics/leak_detector_remote_controller.h" | |
| 12 #include "components/metrics/leak_detector/leak_detector.h" | 13 #include "components/metrics/leak_detector/leak_detector.h" |
| 13 #include "components/metrics/proto/memory_leak_report.pb.h" | 14 #include "components/metrics/proto/memory_leak_report.pb.h" |
| 14 | 15 |
| 15 namespace metrics { | 16 namespace metrics { |
| 16 | 17 |
| 17 // This class initializes the LeakDetector on the browser process and registers | 18 // This class initializes the LeakDetector on the browser process and registers |
| 18 // itself to be notified of leak reports. | 19 // itself to be notified of leak reports. |
| 19 class LeakDetectorController : public LeakDetector::Observer { | 20 class LeakDetectorController |
| 21 : public LeakDetector::Observer, | |
| 22 public LeakDetectorRemoteController::LocalController { | |
| 20 public: | 23 public: |
| 21 LeakDetectorController(); | 24 LeakDetectorController(); |
| 22 ~LeakDetectorController() override; | 25 ~LeakDetectorController() override; |
| 23 | 26 |
| 24 // Retrieves all reports in |stored_reports_|, moving them to |*reports|. | 27 // Retrieves all reports in |stored_reports_|, moving them to |*reports|. |
| 25 // |stored_reports_| is empty afterwards. | 28 // |stored_reports_| is empty afterwards. |
| 26 void GetLeakReports(std::vector<MemoryLeakReportProto>* reports); | 29 void GetLeakReports(std::vector<MemoryLeakReportProto>* reports); |
| 27 | 30 |
| 28 protected: | 31 protected: |
| 29 // LeakDetector::Observer: | 32 // LeakDetector::Observer: |
| 30 void OnLeaksFound(const std::vector<MemoryLeakReportProto>& reports) override; | 33 void OnLeaksFound(const std::vector<MemoryLeakReportProto>& reports) override; |
| 31 | 34 |
| 35 // LeakDetectorRemoteController::LocalController | |
| 36 void GetParams(MemoryLeakReportProto_Params* params) const override; | |
| 37 | |
| 38 // LeakDetectorRemoteController::LocalController | |
|
Ilya Sherman
2016/06/07 23:03:38
nit: Please remove this line and the blank one abo
Simon Que
2016/06/08 01:14:18
Done.
| |
| 39 void SendLeakReports( | |
| 40 const std::vector<MemoryLeakReportProto>& reports) override; | |
| 41 | |
| 32 private: | 42 private: |
| 33 // All leak reports received through OnLeakFound() are stored in protobuf | 43 // All leak reports received through OnLeakFound() are stored in protobuf |
| 34 // format. | 44 // format. |
| 35 std::vector<MemoryLeakReportProto> stored_reports_; | 45 std::vector<MemoryLeakReportProto> stored_reports_; |
| 36 | 46 |
| 37 // Contains all the parameters passed to LeakDetector. Store them in a single | 47 // Contains all the parameters passed to LeakDetector. Store them in a single |
| 38 // protobuf message instead of in separate member variables. | 48 // protobuf message instead of in separate member variables. |
| 39 const MemoryLeakReportProto::Params params_; | 49 const MemoryLeakReportProto::Params params_; |
| 40 | 50 |
| 41 // For thread safety. | 51 // For thread safety. |
| 42 base::ThreadChecker thread_checker_; | 52 base::ThreadChecker thread_checker_; |
| 43 | 53 |
| 44 DISALLOW_COPY_AND_ASSIGN(LeakDetectorController); | 54 DISALLOW_COPY_AND_ASSIGN(LeakDetectorController); |
| 45 }; | 55 }; |
| 46 | 56 |
| 47 } // namespace metrics | 57 } // namespace metrics |
| 48 | 58 |
| 49 #endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ | 59 #endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ |
| OLD | NEW |