| 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_IMPL_H_ | 5 #ifndef COMPONENTS_RAPPOR_RAPPOR_SERVICE_IMPL_H_ |
| 6 #define COMPONENTS_RAPPOR_RAPPOR_SERVICE_IMPL_H_ | 6 #define COMPONENTS_RAPPOR_RAPPOR_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Add an observer for collecting daily metrics. | 49 // Add an observer for collecting daily metrics. |
| 50 void AddDailyObserver( | 50 void AddDailyObserver( |
| 51 std::unique_ptr<metrics::DailyEvent::Observer> observer); | 51 std::unique_ptr<metrics::DailyEvent::Observer> observer); |
| 52 | 52 |
| 53 // Initializes the rappor service, including loading the cohort and secret | 53 // Initializes the rappor service, including loading the cohort and secret |
| 54 // preferences from disk. | 54 // preferences from disk. |
| 55 void Initialize(net::URLRequestContextGetter* context); | 55 void Initialize(net::URLRequestContextGetter* context); |
| 56 | 56 |
| 57 // Updates the settings for metric recording and uploading. | 57 // Updates the settings for metric recording and uploading. |
| 58 // The RapporServiceImpl must be initialized before this method is called. | 58 // The RapporServiceImpl must be initialized before this method is called. |
| 59 // |recording_groups| should be set of flags, e.g. | 59 // If |may_record| is true, data will be recorded and periodic reports will |
| 60 // UMA_RECORDING_GROUP | SAFEBROWSING_RECORDING_GROUP | 60 // be generated and queued for upload. |
| 61 // If it contains any enabled groups, periodic reports will be | |
| 62 // generated and queued for upload. | |
| 63 // If |may_upload| is true, reports will be uploaded from the queue. | 61 // If |may_upload| is true, reports will be uploaded from the queue. |
| 64 void Update(int recording_groups, bool may_upload); | 62 void Update(bool may_record, bool may_upload); |
| 65 | 63 |
| 66 // Constructs a Sample object for the caller to record fields in. | 64 // Constructs a Sample object for the caller to record fields in. |
| 67 std::unique_ptr<Sample> CreateSample(RapporType) override; | 65 std::unique_ptr<Sample> CreateSample(RapporType) override; |
| 68 | 66 |
| 69 // Records a Sample of rappor metric specified by |metric_name|. | 67 // Records a Sample of rappor metric specified by |metric_name|. |
| 70 // | 68 // |
| 71 // example: | 69 // example: |
| 72 // std::unique_ptr<Sample> sample = | 70 // std::unique_ptr<Sample> sample = |
| 73 // rappor_service->CreateSample(MY_METRIC_TYPE); | 71 // rappor_service->CreateSample(MY_METRIC_TYPE); |
| 74 // sample->SetStringField("Field1", "some string"); | 72 // sample->SetStringField("Field1", "some string"); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 145 |
| 148 // Timer which schedules calls to OnLogInterval(). | 146 // Timer which schedules calls to OnLogInterval(). |
| 149 base::OneShotTimer log_rotation_timer_; | 147 base::OneShotTimer log_rotation_timer_; |
| 150 | 148 |
| 151 // A daily event for collecting metrics once a day. | 149 // A daily event for collecting metrics once a day. |
| 152 metrics::DailyEvent daily_event_; | 150 metrics::DailyEvent daily_event_; |
| 153 | 151 |
| 154 // A private LogUploader instance for sending reports to the server. | 152 // A private LogUploader instance for sending reports to the server. |
| 155 std::unique_ptr<LogUploaderInterface> uploader_; | 153 std::unique_ptr<LogUploaderInterface> uploader_; |
| 156 | 154 |
| 157 // The set of recording groups that metrics are being recorded, e.g. | 155 // Whether new data can be recorded. |
| 158 // UMA_RECORDING_GROUP | SAFEBROWSING_RECORDING_GROUP | 156 bool recording_enabled_; |
| 159 int recording_groups_; | |
| 160 | 157 |
| 161 // We keep all registered metrics in a map, from name to metric. | 158 // We keep all registered metrics in a map, from name to metric. |
| 162 std::map<std::string, std::unique_ptr<RapporMetric>> metrics_map_; | 159 std::map<std::string, std::unique_ptr<RapporMetric>> metrics_map_; |
| 163 | 160 |
| 164 internal::Sampler sampler_; | 161 internal::Sampler sampler_; |
| 165 | 162 |
| 166 base::ThreadChecker thread_checker_; | 163 base::ThreadChecker thread_checker_; |
| 167 | 164 |
| 168 DISALLOW_COPY_AND_ASSIGN(RapporServiceImpl); | 165 DISALLOW_COPY_AND_ASSIGN(RapporServiceImpl); |
| 169 }; | 166 }; |
| 170 | 167 |
| 171 } // namespace rappor | 168 } // namespace rappor |
| 172 | 169 |
| 173 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_IMPL_H_ | 170 #endif // COMPONENTS_RAPPOR_RAPPOR_SERVICE_IMPL_H_ |
| OLD | NEW |