| 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 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // This class provides an interface for recording samples for rappor metrics, | 37 // This class provides an interface for recording samples for rappor metrics, |
| 38 // and periodically generates and uploads reports based on the collected data. | 38 // and periodically generates and uploads reports based on the collected data. |
| 39 class RapporService { | 39 class RapporService { |
| 40 public: | 40 public: |
| 41 RapporService(); | 41 RapporService(); |
| 42 virtual ~RapporService(); | 42 virtual ~RapporService(); |
| 43 | 43 |
| 44 // Starts the periodic generation of reports and upload attempts. | 44 // Starts the periodic generation of reports and upload attempts. |
| 45 void Start(PrefService* pref_service, net::URLRequestContextGetter* context); | 45 void Start(PrefService* pref_service, |
| 46 net::URLRequestContextGetter* context, |
| 47 bool metrics_enabled); |
| 46 | 48 |
| 47 // Records a sample of the rappor metric specified by |metric_name|. | 49 // Records a sample of the rappor metric specified by |metric_name|. |
| 48 // Creates and initializes the metric, if it doesn't yet exist. | 50 // Creates and initializes the metric, if it doesn't yet exist. |
| 49 void RecordSample(const std::string& metric_name, | 51 void RecordSample(const std::string& metric_name, |
| 50 RapporType type, | 52 RapporType type, |
| 51 const std::string& sample); | 53 const std::string& sample); |
| 52 | 54 |
| 53 // Sets the cohort value. For use by tests only. | 55 // Sets the cohort value. For use by tests only. |
| 54 void SetCohortForTesting(uint32_t cohort) { cohort_ = cohort; } | 56 void SetCohortForTesting(uint32_t cohort) { cohort_ = cohort; } |
| 55 | 57 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // We keep all registered metrics in a map, from name to metric. | 112 // We keep all registered metrics in a map, from name to metric. |
| 111 // The map owns the metrics it contains. | 113 // The map owns the metrics it contains. |
| 112 std::map<std::string, RapporMetric*> metrics_map_; | 114 std::map<std::string, RapporMetric*> metrics_map_; |
| 113 | 115 |
| 114 DISALLOW_COPY_AND_ASSIGN(RapporService); | 116 DISALLOW_COPY_AND_ASSIGN(RapporService); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 } // namespace rappor | 119 } // namespace rappor |
| 118 | 120 |
| 119 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ | 121 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_H_ |
| OLD | NEW |