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

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

Issue 2617883004: Initial UKMPageLoadMetricsObserver (Closed)
Patch Set: Created 3 years, 11 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 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "components/metrics/metrics_reporting_scheduler.h" 13 #include "components/metrics/metrics_reporting_scheduler.h"
14 #include "components/metrics/persisted_logs.h" 14 #include "components/metrics/persisted_logs.h"
15 15
16 class PrefRegistrySimple; 16 class PrefRegistrySimple;
17 class PrefService; 17 class PrefService;
18 18
19 namespace metrics { 19 namespace metrics {
20 class MetricsLogUploader; 20 class MetricsLogUploader;
21 class MetricsServiceClient; 21 class MetricsServiceClient;
22 } 22 }
23 23
24 namespace ukm { 24 namespace ukm {
25 25
26 class UkmSource;
27
26 // Manages the generation and uploading of UKM reports. 28 // Manages the generation and uploading of UKM reports.
27 // These reports contained fine grained performance metrics including URLs for 29 // These reports contained fine grained performance metrics including URLs for
28 // top-level navigations. 30 // top-level navigations.
29 class UkmService : public base::SupportsWeakPtr<UkmService> { 31 class UkmService : public base::SupportsWeakPtr<UkmService> {
30 public: 32 public:
31 // Constructs a UkmService. 33 // Constructs a UkmService.
32 // Calling code is responsible for ensuring that the lifetime of 34 // Calling code is responsible for ensuring that the lifetime of
33 // |pref_service| is longer than the lifetime of UkmService. 35 // |pref_service| is longer than the lifetime of UkmService.
34 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client); 36 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client);
35 virtual ~UkmService(); 37 virtual ~UkmService();
36 38
37 // Initializes the UKM service. 39 // Initializes the UKM service.
38 void Initialize(); 40 void Initialize();
39 41
40 // Enable/disable transmission of accumulated logs. Logs that have already 42 // Enable/disable transmission of accumulated logs. Logs that have already
41 // been created will remain persisted to disk. 43 // been created will remain persisted to disk.
42 void EnableReporting(); 44 void EnableReporting();
43 void DisableReporting(); 45 void DisableReporting();
44 46
47 void RecordSource(std::unique_ptr<UkmSource> source);
48
45 // Registers the names of all of the preferences used by UkmService in 49 // Registers the names of all of the preferences used by UkmService in
46 // the provided PrefRegistry. 50 // the provided PrefRegistry.
47 static void RegisterPrefs(PrefRegistrySimple* registry); 51 static void RegisterPrefs(PrefRegistrySimple* registry);
48 52
49 private: 53 private:
50 // Start metrics client initialization. 54 // Start metrics client initialization.
51 void StartInitTask(); 55 void StartInitTask();
52 56
53 // Called when initialization tasks are complete, to notify the scheduler 57 // Called when initialization tasks are complete, to notify the scheduler
54 // that it can begin calling RotateLog. 58 // that it can begin calling RotateLog.
(...skipping 29 matching lines...) Expand all
84 std::unique_ptr<metrics::MetricsReportingScheduler> scheduler_; 88 std::unique_ptr<metrics::MetricsReportingScheduler> scheduler_;
85 89
86 base::ThreadChecker thread_checker_; 90 base::ThreadChecker thread_checker_;
87 91
88 // Instance of the helper class for uploading logs. 92 // Instance of the helper class for uploading logs.
89 std::unique_ptr<metrics::MetricsLogUploader> log_uploader_; 93 std::unique_ptr<metrics::MetricsLogUploader> log_uploader_;
90 94
91 bool initialize_started_; 95 bool initialize_started_;
92 bool log_upload_in_progress_; 96 bool log_upload_in_progress_;
93 97
98 std::vector<std::unique_ptr<UkmSource>> sources_;
99
94 // Weak pointers factory used to post task on different threads. All weak 100 // Weak pointers factory used to post task on different threads. All weak
95 // pointers managed by this factory have the same lifetime as UkmService. 101 // pointers managed by this factory have the same lifetime as UkmService.
96 base::WeakPtrFactory<UkmService> self_ptr_factory_; 102 base::WeakPtrFactory<UkmService> self_ptr_factory_;
97 103
98 DISALLOW_COPY_AND_ASSIGN(UkmService); 104 DISALLOW_COPY_AND_ASSIGN(UkmService);
99 }; 105 };
100 106
101 } // namespace ukm 107 } // namespace ukm
102 108
103 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 109 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698