OLD | NEW |
(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 // HistogramFlattener methods: |
| 42 void RecordDelta(const base::HistogramBase& histogram, |
| 43 const base::HistogramSamples& snapshot) override; |
| 44 void InconsistencyDetected( |
| 45 base::HistogramBase::Inconsistency problem) override; |
| 46 void UniqueInconsistencyDetected( |
| 47 base::HistogramBase::Inconsistency problem) override; |
| 48 void InconsistencyDetectedInLoggedCount(int amount) override; |
| 49 |
| 50 void RecordHistogramDelta(const std::string& histogram_name, |
| 51 const base::HistogramSamples& snapshot); |
| 52 |
| 53 base::HistogramSnapshotManager histogram_snapshot_manager_; |
| 54 |
| 55 // Stores the protocol buffer representation for this log. |
| 56 metrics::ChromeUserMetricsExtension uma_proto_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(HistogramManager); |
| 59 }; |
| 60 |
| 61 } // namespace cronet |
| 62 |
| 63 #endif // COMPONENTS_CRONET_ANDROID_CRONET_HISTOGRAM_MANAGER_H_ |
OLD | NEW |