Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: components/ukm/ukm_service.h

Issue 2770853002: Create Ukm ReportingService implementation. (Closed)
Patch Set: Fix register prefs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // The UKM session id stored in prefs. 161 // The UKM session id stored in prefs.
163 int32_t session_id_; 162 int32_t session_id_;
164 163
165 // Used to interact with the embedder. Weak pointer; must outlive |this| 164 // Used to interact with the embedder. Weak pointer; must outlive |this|
166 // instance. 165 // instance.
167 metrics::MetricsServiceClient* const client_; 166 metrics::MetricsServiceClient* const client_;
168 167
169 // Registered metrics providers. 168 // Registered metrics providers.
170 std::vector<std::unique_ptr<metrics::MetricsProvider>> metrics_providers_; 169 std::vector<std::unique_ptr<metrics::MetricsProvider>> metrics_providers_;
171 170
172 // Logs that have not yet been sent. 171 // Log reporting service.
173 metrics::PersistedLogs persisted_logs_; 172 ukm::UkmReportingService reporting_service_;
174 173
175 // The scheduler for determining when uploads should happen. 174 // The scheduler for determining when uploads should happen.
176 std::unique_ptr<metrics::MetricsReportingScheduler> scheduler_; 175 std::unique_ptr<metrics::MetricsRotationScheduler> scheduler_;
177 176
178 base::ThreadChecker thread_checker_; 177 base::ThreadChecker thread_checker_;
179 178
180 // Instance of the helper class for uploading logs.
181 std::unique_ptr<metrics::MetricsLogUploader> log_uploader_;
182
183 bool initialize_started_; 179 bool initialize_started_;
184 bool initialize_complete_; 180 bool initialize_complete_;
185 bool log_upload_in_progress_;
186 181
187 // Contains newly added sources and entries of UKM metrics which periodically 182 // Contains newly added sources and entries of UKM metrics which periodically
188 // get serialized and cleared by BuildAndStoreLog(). 183 // get serialized and cleared by BuildAndStoreLog().
189 std::map<int32_t, std::unique_ptr<UkmSource>> sources_; 184 std::map<int32_t, std::unique_ptr<UkmSource>> sources_;
190 std::vector<std::unique_ptr<UkmEntry>> entries_; 185 std::vector<std::unique_ptr<UkmEntry>> entries_;
191 186
192 // Weak pointers factory used to post task on different threads. All weak 187 // Weak pointers factory used to post task on different threads. All weak
193 // pointers managed by this factory have the same lifetime as UkmService. 188 // pointers managed by this factory have the same lifetime as UkmService.
194 base::WeakPtrFactory<UkmService> self_ptr_factory_; 189 base::WeakPtrFactory<UkmService> self_ptr_factory_;
195 190
196 DISALLOW_COPY_AND_ASSIGN(UkmService); 191 DISALLOW_COPY_AND_ASSIGN(UkmService);
197 }; 192 };
198 193
199 } // namespace ukm 194 } // namespace ukm
200 195
201 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 196 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698