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

Side by Side Diff: components/cronet/android/histogram_manager.h

Issue 794493002: Add UMA Histogram Manager to Cronet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added end to end unittest Created 6 years 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
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_HISTOGRAM_MANAGER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_HISTOGRAM_MANAGER_H_
7
8 #include <jni.h>
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/singleton.h"
16 #include "base/metrics/histogram_flattener.h"
17 #include "base/metrics/histogram_snapshot_manager.h"
18 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
19
20 namespace cronet {
21
22 bool HistogramManagerRegisterJni(JNIEnv* env);
23
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 {
28 public:
29 HistogramManager();
30 ~HistogramManager();
31
32 // Snapshot all histograms to record the delta into |uma_proto_| and then
33 // returns the serialized protobuf representation of the record.
34 std::vector<uint8> GetDeltas();
35
36 // TODO(mef): Hang Histogram Manager off java object instead of singleton.
37 static HistogramManager* GetInstance();
38
39 private:
40 friend struct DefaultSingletonTraits<HistogramManager>;
41
42 // HistogramFlattener methods:
43 void RecordDelta(const base::HistogramBase& histogram,
44 const base::HistogramSamples& snapshot) override;
45 void InconsistencyDetected(
46 base::HistogramBase::Inconsistency problem) override;
47 void UniqueInconsistencyDetected(
48 base::HistogramBase::Inconsistency problem) override;
49 void InconsistencyDetectedInLoggedCount(int amount) override;
50
51 void RecordHistogramDelta(const std::string& histogram_name,
52 const base::HistogramSamples& snapshot);
53
54 base::HistogramSnapshotManager histogram_snapshot_manager_;
55
56 // Stores the protocol buffer representation for this log.
57 metrics::ChromeUserMetricsExtension uma_proto_;
58
59 DISALLOW_COPY_AND_ASSIGN(HistogramManager);
60 };
61
62 } // namespace cronet
63
64 #endif // COMPONENTS_CRONET_ANDROID_CRONET_HISTOGRAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698