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