OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_METRICS_METRICS_SERVICE_BASE_H_ | 5 #ifndef CHROME_COMMON_METRICS_METRICS_SERVICE_BASE_H_ |
6 #define CHROME_COMMON_METRICS_METRICS_SERVICE_BASE_H_ | 6 #define CHROME_COMMON_METRICS_METRICS_SERVICE_BASE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/common/metrics/histogram_sender.h" | 10 #include "base/metrics/histogram_flattener.h" |
| 11 #include "base/metrics/histogram_snapshot_manager.h" |
11 #include "chrome/common/metrics/metrics_log_manager.h" | 12 #include "chrome/common/metrics/metrics_log_manager.h" |
12 | 13 |
13 // This class provides base functionality for logging metrics data. | 14 // This class provides base functionality for logging metrics data. |
14 // TODO(ananta): Factor out more common code from chrome and chrome frame | 15 // TODO(ananta): Factor out more common code from chrome and chrome frame |
15 // metrics service into this class. | 16 // metrics service into this class. |
16 class MetricsServiceBase : public HistogramSender { | 17 class MetricsServiceBase : public base::HistogramFlattener { |
| 18 public: |
| 19 // HistogramFlattener interface (override) methods. |
| 20 virtual void RecordDelta(const base::Histogram& histogram, |
| 21 const base::Histogram::SampleSet& snapshot) OVERRIDE; |
| 22 virtual void InconsistencyDetected(int problem) OVERRIDE; |
| 23 virtual void UniqueInconsistencyDetected(int problem) OVERRIDE; |
| 24 virtual void SnapshotProblemResolved(int amount) OVERRIDE; |
| 25 |
17 protected: | 26 protected: |
18 MetricsServiceBase(); | 27 MetricsServiceBase(); |
19 virtual ~MetricsServiceBase(); | 28 virtual ~MetricsServiceBase(); |
20 | 29 |
21 // The metrics servers' URLs, for XML and protobuf uploads. | 30 // The metrics servers' URLs, for XML and protobuf uploads. |
22 static const char kServerUrlXml[]; | 31 static const char kServerUrlXml[]; |
23 static const char kServerUrlProto[]; | 32 static const char kServerUrlProto[]; |
24 | 33 |
25 // The MIME types for the uploaded metrics data, for XML and protobuf uploads. | 34 // The MIME types for the uploaded metrics data, for XML and protobuf uploads. |
26 static const char kMimeTypeXml[]; | 35 static const char kMimeTypeXml[]; |
27 static const char kMimeTypeProto[]; | 36 static const char kMimeTypeProto[]; |
28 | 37 |
29 // Record complete list of histograms into the current log. | 38 // Record complete list of histograms into the current log. |
30 // Called when we close a log. | 39 // Called when we close a log. |
31 void RecordCurrentHistograms(); | 40 void RecordCurrentHistograms(); |
32 | 41 |
33 // Manager for the various in-flight logs. | 42 // Manager for the various in-flight logs. |
34 MetricsLogManager log_manager_; | 43 MetricsLogManager log_manager_; |
35 | 44 |
36 private: | 45 private: |
37 // HistogramSender interface (override) methods. | 46 // |histogram_snapshot_manager_| prepares histogram deltas for transmission. |
38 virtual void TransmitHistogramDelta( | 47 base::HistogramSnapshotManager histogram_snapshot_manager_; |
39 const base::Histogram& histogram, | |
40 const base::Histogram::SampleSet& snapshot) OVERRIDE; | |
41 virtual void InconsistencyDetected(int problem) OVERRIDE; | |
42 virtual void UniqueInconsistencyDetected(int problem) OVERRIDE; | |
43 virtual void SnapshotProblemResolved(int amount) OVERRIDE; | |
44 | 48 |
45 DISALLOW_COPY_AND_ASSIGN(MetricsServiceBase); | 49 DISALLOW_COPY_AND_ASSIGN(MetricsServiceBase); |
46 }; | 50 }; |
47 | 51 |
48 #endif // CHROME_COMMON_METRICS_METRICS_SERVICE_BASE_H_ | 52 #endif // CHROME_COMMON_METRICS_METRICS_SERVICE_BASE_H_ |
OLD | NEW |