1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_METRICS_HISTOGRAM_MANAGER_H_
6 #define COMPONENTS_METRICS_HISTOGRAM_MANAGER_H_
11 #include "base/basictypes.h"
12 #include "base/lazy_instance.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram_flattener.h"
16 #include "base/metrics/histogram_snapshot_manager.h"
17 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
21 // TODO(mef): crbug.com/441441. Move components/metrics/histogram_manager.*
22 // files into components/android/cronet.
24 // A HistogramManager instance is created by Android. It is the central
25 // controller for the acquisition of log data, and the automatic transmission of
26 // that log data to an external server.
27 class HistogramManager
: public base::HistogramFlattener
{
30 ~HistogramManager() override
;
32 // Snapshot all histograms to record the delta into |uma_proto_| and then
33 // returns the serialized protobuf representation of the record in |data|.
34 // Returns true if it was successfully serialized.
35 bool GetDeltas(std::vector
<uint8
>* data
);
37 // TODO(mef): Hang Histogram Manager off java object instead of singleton.
38 static HistogramManager
* GetInstance();
41 friend struct base::DefaultLazyInstanceTraits
<HistogramManager
>;
43 // base::HistogramFlattener:
44 void RecordDelta(const base::HistogramBase
& histogram
,
45 const base::HistogramSamples
& snapshot
) override
;
46 void InconsistencyDetected(
47 base::HistogramBase::Inconsistency problem
) override
;
48 void UniqueInconsistencyDetected(
49 base::HistogramBase::Inconsistency problem
) override
;
50 void InconsistencyDetectedInLoggedCount(int amount
) override
;
52 base::HistogramSnapshotManager histogram_snapshot_manager_
;
54 // Stores the protocol buffer representation for this log.
55 metrics::ChromeUserMetricsExtension uma_proto_
;
57 DISALLOW_COPY_AND_ASSIGN(HistogramManager
);
60 } // namespace metrics
62 #endif // COMPONENTS_METRICS_HISTOGRAM_MANAGER_H_