| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_UKM_UKM_SERVICE_H_ | 5 #ifndef COMPONENTS_UKM_UKM_SERVICE_H_ |
| 6 #define COMPONENTS_UKM_UKM_SERVICE_H_ | 6 #define COMPONENTS_UKM_UKM_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/feature_list.h" | 13 #include "base/feature_list.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "components/metrics/metrics_provider.h" | 18 #include "components/metrics/metrics_provider.h" |
| 19 #include "components/metrics/metrics_reporting_scheduler.h" | 19 #include "components/metrics/metrics_rotation_scheduler.h" |
| 20 #include "components/metrics/persisted_logs.h" | 20 #include "components/ukm/ukm_reporting_service.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
| 24 class PrefService; | 24 class PrefService; |
| 25 class UkmPageLoadMetricsObserver; | 25 class UkmPageLoadMetricsObserver; |
| 26 | 26 |
| 27 namespace autofill { | 27 namespace autofill { |
| 28 class AutofillMetrics; | 28 class AutofillMetrics; |
| 29 } // namespace autofill | 29 } // namespace autofill |
| 30 | 30 |
| 31 namespace metrics { | 31 namespace metrics { |
| 32 class MetricsLogUploader; | |
| 33 class MetricsServiceClient; | 32 class MetricsServiceClient; |
| 34 } | 33 } |
| 35 | 34 |
| 36 namespace ukm { | 35 namespace ukm { |
| 37 | 36 |
| 38 class UkmEntry; | 37 class UkmEntry; |
| 39 class UkmEntryBuilder; | 38 class UkmEntryBuilder; |
| 40 class UkmSource; | 39 class UkmSource; |
| 41 | 40 |
| 42 // This feature controls whether UkmService should be created. | 41 // This feature controls whether UkmService should be created. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // The UKM session id stored in prefs. | 165 // The UKM session id stored in prefs. |
| 167 int32_t session_id_; | 166 int32_t session_id_; |
| 168 | 167 |
| 169 // Used to interact with the embedder. Weak pointer; must outlive |this| | 168 // Used to interact with the embedder. Weak pointer; must outlive |this| |
| 170 // instance. | 169 // instance. |
| 171 metrics::MetricsServiceClient* const client_; | 170 metrics::MetricsServiceClient* const client_; |
| 172 | 171 |
| 173 // Registered metrics providers. | 172 // Registered metrics providers. |
| 174 std::vector<std::unique_ptr<metrics::MetricsProvider>> metrics_providers_; | 173 std::vector<std::unique_ptr<metrics::MetricsProvider>> metrics_providers_; |
| 175 | 174 |
| 176 // Logs that have not yet been sent. | 175 // Log reporting service. |
| 177 metrics::PersistedLogs persisted_logs_; | 176 ukm::UkmReportingService reporting_service_; |
| 178 | 177 |
| 179 // The scheduler for determining when uploads should happen. | 178 // The scheduler for determining when uploads should happen. |
| 180 std::unique_ptr<metrics::MetricsReportingScheduler> scheduler_; | 179 std::unique_ptr<metrics::MetricsRotationScheduler> scheduler_; |
| 181 | 180 |
| 182 base::ThreadChecker thread_checker_; | 181 base::ThreadChecker thread_checker_; |
| 183 | 182 |
| 184 // Instance of the helper class for uploading logs. | |
| 185 std::unique_ptr<metrics::MetricsLogUploader> log_uploader_; | |
| 186 | |
| 187 bool initialize_started_; | 183 bool initialize_started_; |
| 188 bool initialize_complete_; | 184 bool initialize_complete_; |
| 189 bool log_upload_in_progress_; | |
| 190 | 185 |
| 191 // Contains newly added sources and entries of UKM metrics which periodically | 186 // Contains newly added sources and entries of UKM metrics which periodically |
| 192 // get serialized and cleared by BuildAndStoreLog(). | 187 // get serialized and cleared by BuildAndStoreLog(). |
| 193 std::map<int32_t, std::unique_ptr<UkmSource>> sources_; | 188 std::map<int32_t, std::unique_ptr<UkmSource>> sources_; |
| 194 std::vector<std::unique_ptr<UkmEntry>> entries_; | 189 std::vector<std::unique_ptr<UkmEntry>> entries_; |
| 195 | 190 |
| 196 // Whitelisted Entry hashes, only the ones in this set will be recorded. | 191 // Whitelisted Entry hashes, only the ones in this set will be recorded. |
| 197 std::set<uint64_t> whitelisted_entry_hashes_; | 192 std::set<uint64_t> whitelisted_entry_hashes_; |
| 198 | 193 |
| 199 // Weak pointers factory used to post task on different threads. All weak | 194 // Weak pointers factory used to post task on different threads. All weak |
| 200 // pointers managed by this factory have the same lifetime as UkmService. | 195 // pointers managed by this factory have the same lifetime as UkmService. |
| 201 base::WeakPtrFactory<UkmService> self_ptr_factory_; | 196 base::WeakPtrFactory<UkmService> self_ptr_factory_; |
| 202 | 197 |
| 203 DISALLOW_COPY_AND_ASSIGN(UkmService); | 198 DISALLOW_COPY_AND_ASSIGN(UkmService); |
| 204 }; | 199 }; |
| 205 | 200 |
| 206 } // namespace ukm | 201 } // namespace ukm |
| 207 | 202 |
| 208 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ | 203 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ |
| OLD | NEW |