blob: 4207afcf64efcd198c7ba4a1d4cf800f4dfa8ad1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// 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 "base/threading/thread_checker.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() override;
// Retrieves all reports in |stored_reports_|, moving them to |*reports|.
// |stored_reports_| is empty afterwards.
void GetLeakReports(std::vector<MemoryLeakReportProto>* reports);
protected:
// LeakDetector::Observer:
void OnLeakFound(const LeakDetector::LeakReport& report) override;
private:
// All leak reports received through OnLeakFound() are stored in protobuf
// format.
std::vector<MemoryLeakReportProto> stored_reports_;
// For thread safety.
base::ThreadChecker thread_checker_;
DISALLOW_COPY_AND_ASSIGN(LeakDetectorController);
};
} // namespace metrics
#endif // CHROME_BROWSER_METRICS_LEAK_DETECTOR_CONTROLLER_H_
|