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

Side by Side Diff: chrome/browser/metrics/leak_detector_controller.h

Issue 1868193003: Store alloc history data in memory leak report protobuf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@leak-history
Patch Set: Add dependency on protobufs to leak detector tests Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/metrics/leak_detector_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/metrics/leak_detector/leak_detector.h" 12 #include "components/metrics/leak_detector/leak_detector.h"
13 #include "components/metrics/proto/memory_leak_report.pb.h" 13 #include "components/metrics/proto/memory_leak_report.pb.h"
14 14
15 namespace metrics { 15 namespace metrics {
16 16
17 // This class initializes the LeakDetector on the browser process and registers 17 // This class initializes the LeakDetector on the browser process and registers
18 // itself to be notified of leak reports. 18 // itself to be notified of leak reports.
19 class LeakDetectorController : public LeakDetector::Observer { 19 class LeakDetectorController : public LeakDetector::Observer {
20 public: 20 public:
21 LeakDetectorController(); 21 LeakDetectorController();
22 ~LeakDetectorController() override; 22 ~LeakDetectorController() override;
23 23
24 // Retrieves all reports in |stored_reports_|, moving them to |*reports|. 24 // Retrieves all reports in |stored_reports_|, moving them to |*reports|.
25 // |stored_reports_| is empty afterwards. 25 // |stored_reports_| is empty afterwards.
26 void GetLeakReports(std::vector<MemoryLeakReportProto>* reports); 26 void GetLeakReports(std::vector<MemoryLeakReportProto>* reports);
27 27
28 protected: 28 protected:
29 // LeakDetector::Observer: 29 // LeakDetector::Observer:
30 void OnLeakFound(const LeakDetector::LeakReport& report) override; 30 void OnLeaksFound(const std::vector<MemoryLeakReportProto>& reports) override;
31 31
32 private: 32 private:
33 // All leak reports received through OnLeakFound() are stored in protobuf 33 // All leak reports received through OnLeakFound() are stored in protobuf
34 // format. 34 // format.
35 std::vector<MemoryLeakReportProto> stored_reports_; 35 std::vector<MemoryLeakReportProto> stored_reports_;
36 36
37 // All incoming leak reports should be converted to a MemoryLeakReportProto 37 // All incoming leak reports should be converted to a MemoryLeakReportProto
38 // starting with this template, which has some fields already filled in, e.g. 38 // starting with this template, which has some fields already filled in, e.g.
39 // leak detection parameters. Storing the LeakDetector parameters in the 39 // leak detection parameters. Storing the LeakDetector parameters in the
40 // protobuf template avoids having to store these params as individual member 40 // protobuf template avoids having to store these params as individual member
41 // variables. 41 // variables.
42 const MemoryLeakReportProto leak_report_proto_template_; 42 const MemoryLeakReportProto leak_report_proto_template_;
43 43
44 // For thread safety. 44 // For thread safety.
45 base::ThreadChecker thread_checker_; 45 base::ThreadChecker thread_checker_;
46 46
47 DISALLOW_COPY_AND_ASSIGN(LeakDetectorController); 47 DISALLOW_COPY_AND_ASSIGN(LeakDetectorController);
48 }; 48 };
49 49
50 } // namespace metrics 50 } // namespace metrics
51 51
52 #endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_ 52 #endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/leak_detector_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698