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

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

Issue 2653693004: UKM Sync Observer (Closed)
Patch Set: Suppress recording and fix tests Created 3 years, 10 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 10
(...skipping 27 matching lines...) Expand all
38 public: 38 public:
39 // Constructs a UkmService. 39 // Constructs a UkmService.
40 // Calling code is responsible for ensuring that the lifetime of 40 // Calling code is responsible for ensuring that the lifetime of
41 // |pref_service| is longer than the lifetime of UkmService. 41 // |pref_service| is longer than the lifetime of UkmService.
42 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client); 42 UkmService(PrefService* pref_service, metrics::MetricsServiceClient* client);
43 virtual ~UkmService(); 43 virtual ~UkmService();
44 44
45 // Initializes the UKM service. 45 // Initializes the UKM service.
46 void Initialize(); 46 void Initialize();
47 47
48 // Enable/disable recording control if data is allowed to be collected.
49 void EnableRecording();
50 void DisableRecording();
51
48 // Enable/disable transmission of accumulated logs. Logs that have already 52 // Enable/disable transmission of accumulated logs. Logs that have already
49 // been created will remain persisted to disk. 53 // been created will remain persisted to disk.
50 void EnableReporting(); 54 void EnableReporting();
51 void DisableReporting(); 55 void DisableReporting();
52 56
53 // Adds a new source of UKM metrics, which will be stored 57 // Adds a new source of UKM metrics, which will be stored
54 // until periodically serialized for upload, and then deleted. 58 // until periodically serialized for upload, and then deleted.
55 void RecordSource(std::unique_ptr<UkmSource> source); 59 void RecordSource(std::unique_ptr<UkmSource> source);
56 60
57 // Record any collected data into logs, and write to disk. 61 // Record any collected data into logs, and write to disk.
58 void Flush(); 62 void Flush();
59 63
60 // Delete any unsent local data. 64 // Delete any unsent local data.
61 void Purge(); 65 void Purge();
62 66
67 // Resets the client id stored in prefs.
68 void ResetClientId();
69
63 // Registers the names of all of the preferences used by UkmService in 70 // Registers the names of all of the preferences used by UkmService in
64 // the provided PrefRegistry. 71 // the provided PrefRegistry.
65 static void RegisterPrefs(PrefRegistrySimple* registry); 72 static void RegisterPrefs(PrefRegistrySimple* registry);
66 73
67 protected: 74 protected:
68 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const { 75 const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const {
69 return sources_; 76 return sources_;
70 } 77 }
71 78
72 private: 79 private:
(...skipping 13 matching lines...) Expand all
86 93
87 // Start an upload of the next log from persisted_logs_. 94 // Start an upload of the next log from persisted_logs_.
88 void StartScheduledUpload(); 95 void StartScheduledUpload();
89 96
90 // Called by log_uploader_ when the an upload is completed. 97 // Called by log_uploader_ when the an upload is completed.
91 void OnLogUploadComplete(int response_code); 98 void OnLogUploadComplete(int response_code);
92 99
93 // A weak pointer to the PrefService used to read and write preferences. 100 // A weak pointer to the PrefService used to read and write preferences.
94 PrefService* pref_service_; 101 PrefService* pref_service_;
95 102
103 // Whether recording new data is currently allowed.
104 bool recording_enabled_;
105
96 // The UKM client id stored in prefs. 106 // The UKM client id stored in prefs.
97 uint64_t client_id_; 107 uint64_t client_id_;
98 108
99 // Used to interact with the embedder. Weak pointer; must outlive |this| 109 // Used to interact with the embedder. Weak pointer; must outlive |this|
100 // instance. 110 // instance.
101 metrics::MetricsServiceClient* const client_; 111 metrics::MetricsServiceClient* const client_;
102 112
103 // Logs that have not yet been sent. 113 // Logs that have not yet been sent.
104 metrics::PersistedLogs persisted_logs_; 114 metrics::PersistedLogs persisted_logs_;
105 115
(...skipping 16 matching lines...) Expand all
122 // Weak pointers factory used to post task on different threads. All weak 132 // Weak pointers factory used to post task on different threads. All weak
123 // pointers managed by this factory have the same lifetime as UkmService. 133 // pointers managed by this factory have the same lifetime as UkmService.
124 base::WeakPtrFactory<UkmService> self_ptr_factory_; 134 base::WeakPtrFactory<UkmService> self_ptr_factory_;
125 135
126 DISALLOW_COPY_AND_ASSIGN(UkmService); 136 DISALLOW_COPY_AND_ASSIGN(UkmService);
127 }; 137 };
128 138
129 } // namespace ukm 139 } // namespace ukm
130 140
131 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 141 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698