OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ | 5 #ifndef COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ |
6 #define COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ | 6 #define COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "components/metrics/daily_event.h" | 16 #include "components/metrics/daily_event.h" |
17 #include "components/rappor/rappor_parameters.h" | 17 #include "components/rappor/rappor_parameters.h" |
18 #include "components/rappor/sample.h" | |
19 #include "components/rappor/sampler.h" | |
18 | 20 |
19 class PrefRegistrySimple; | 21 class PrefRegistrySimple; |
20 class PrefService; | 22 class PrefService; |
21 | 23 |
22 namespace net { | 24 namespace net { |
23 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
24 } | 26 } |
25 | 27 |
26 namespace rappor { | 28 namespace rappor { |
27 | 29 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 // Records a sample of the rappor metric specified by |metric_name|. | 68 // Records a sample of the rappor metric specified by |metric_name|. |
67 // Creates and initializes the metric, if it doesn't yet exist. | 69 // Creates and initializes the metric, if it doesn't yet exist. |
68 virtual void RecordSample(const std::string& metric_name, | 70 virtual void RecordSample(const std::string& metric_name, |
69 RapporType type, | 71 RapporType type, |
70 const std::string& sample); | 72 const std::string& sample); |
71 | 73 |
72 // Registers the names of all of the preferences used by RapporService in the | 74 // Registers the names of all of the preferences used by RapporService in the |
73 // provided PrefRegistry. This should be called before calling Start(). | 75 // provided PrefRegistry. This should be called before calling Start(). |
74 static void RegisterPrefs(PrefRegistrySimple* registry); | 76 static void RegisterPrefs(PrefRegistrySimple* registry); |
75 | 77 |
78 scoped_ptr<Sample> MakeSampleObj(RapporType); | |
Alexei Svitkine (slow)
2015/04/23 21:42:34
I don't think we should use "SampleObj" in the sig
Steven Holte
2015/04/24 16:59:05
Renamed to CreateSampleObj, but RecordSample is al
| |
79 | |
80 void RecordSampleObj(const std::string& metric_name, | |
81 scoped_ptr<Sample> sample); | |
82 | |
76 protected: | 83 protected: |
77 // Initializes the state of the RapporService. | 84 // Initializes the state of the RapporService. |
78 void InitializeInternal(scoped_ptr<LogUploaderInterface> uploader, | 85 void InitializeInternal(scoped_ptr<LogUploaderInterface> uploader, |
79 int32_t cohort, | 86 int32_t cohort, |
80 const std::string& secret); | 87 const std::string& secret); |
81 | 88 |
82 // Sets the recording level. | 89 // Sets the recording level. |
83 void SetRecordingLevel(RecordingLevel parameters); | 90 void SetRecordingLevel(RecordingLevel parameters); |
84 | 91 |
85 // Cancels the next call to OnLogInterval. | 92 // Cancels the next call to OnLogInterval. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 // A private LogUploader instance for sending reports to the server. | 141 // A private LogUploader instance for sending reports to the server. |
135 scoped_ptr<LogUploaderInterface> uploader_; | 142 scoped_ptr<LogUploaderInterface> uploader_; |
136 | 143 |
137 // What reporting level of metrics are being reported. | 144 // What reporting level of metrics are being reported. |
138 RecordingLevel recording_level_; | 145 RecordingLevel recording_level_; |
139 | 146 |
140 // We keep all registered metrics in a map, from name to metric. | 147 // We keep all registered metrics in a map, from name to metric. |
141 // The map owns the metrics it contains. | 148 // The map owns the metrics it contains. |
142 std::map<std::string, RapporMetric*> metrics_map_; | 149 std::map<std::string, RapporMetric*> metrics_map_; |
143 | 150 |
151 internal::Sampler sampler_; | |
152 | |
144 DISALLOW_COPY_AND_ASSIGN(RapporService); | 153 DISALLOW_COPY_AND_ASSIGN(RapporService); |
145 }; | 154 }; |
146 | 155 |
147 } // namespace rappor | 156 } // namespace rappor |
148 | 157 |
149 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ | 158 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ |
OLD | NEW |