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

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

Issue 2749433002: Create Field Trial param for whitelisting UKM Entries. (Closed)
Patch Set: add comment 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>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 private: 106 private:
107 friend UkmPageLoadMetricsObserver; 107 friend UkmPageLoadMetricsObserver;
108 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics); 108 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics);
109 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); 109 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization);
110 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, 110 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest,
111 LogsUploadedOnlyWhenHavingSourcesOrEntries); 111 LogsUploadedOnlyWhenHavingSourcesOrEntries);
112 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); 112 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest);
113 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); 113 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge);
114 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest);
114 115
115 // Get a new UkmEntryBuilder object for the specified source ID and event, 116 // Get a new UkmEntryBuilder object for the specified source ID and event,
116 // which can get metrics added to. 117 // which can get metrics added to.
117 // 118 //
118 // This API being private is intentional. Any client using UKM needs to 119 // This API being private is intentional. Any client using UKM needs to
119 // declare itself to be a friend of UkmService and go through code review 120 // declare itself to be a friend of UkmService and go through code review
120 // process. 121 // process.
121 std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(int32_t source_id, 122 std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(int32_t source_id,
122 const char* event_name); 123 const char* event_name);
123 124
(...skipping 18 matching lines...) Expand all
142 143
143 // Starts an upload of the next log from persisted_logs_. 144 // Starts an upload of the next log from persisted_logs_.
144 void StartScheduledUpload(); 145 void StartScheduledUpload();
145 146
146 // Called by log_uploader_ when the an upload is completed. 147 // Called by log_uploader_ when the an upload is completed.
147 void OnLogUploadComplete(int response_code); 148 void OnLogUploadComplete(int response_code);
148 149
149 // Add an entry to the UkmEntry list. 150 // Add an entry to the UkmEntry list.
150 void AddEntry(std::unique_ptr<UkmEntry> entry); 151 void AddEntry(std::unique_ptr<UkmEntry> entry);
151 152
153 // Cache the list of whitelisted entries from the field trial parameter.
154 void StoreWhitelistedEntries();
155
152 // A weak pointer to the PrefService used to read and write preferences. 156 // A weak pointer to the PrefService used to read and write preferences.
153 PrefService* pref_service_; 157 PrefService* pref_service_;
154 158
155 // Whether recording new data is currently allowed. 159 // Whether recording new data is currently allowed.
156 bool recording_enabled_; 160 bool recording_enabled_;
157 161
158 // The UKM client id stored in prefs. 162 // The UKM client id stored in prefs.
159 uint64_t client_id_; 163 uint64_t client_id_;
160 164
161 // The UKM session id stored in prefs. 165 // The UKM session id stored in prefs.
(...skipping 20 matching lines...) Expand all
182 bool initialize_started_; 186 bool initialize_started_;
183 bool initialize_complete_; 187 bool initialize_complete_;
184 bool log_upload_in_progress_; 188 bool log_upload_in_progress_;
185 189
186 // Contains newly added sources and entries of UKM metrics which periodically 190 // Contains newly added sources and entries of UKM metrics which periodically
187 // get serialized and cleared by BuildAndStoreLog(). 191 // get serialized and cleared by BuildAndStoreLog().
188 // TODO(zhenw): update sources to a map keyed by source ID. 192 // TODO(zhenw): update sources to a map keyed by source ID.
189 std::vector<std::unique_ptr<UkmSource>> sources_; 193 std::vector<std::unique_ptr<UkmSource>> sources_;
190 std::vector<std::unique_ptr<UkmEntry>> entries_; 194 std::vector<std::unique_ptr<UkmEntry>> entries_;
191 195
196 // Whitelisted Entry hashes, only the ones in this set will be recorded.
197 std::set<uint64_t> whitelisted_entry_hashes_;
198
192 // Weak pointers factory used to post task on different threads. All weak 199 // Weak pointers factory used to post task on different threads. All weak
193 // pointers managed by this factory have the same lifetime as UkmService. 200 // pointers managed by this factory have the same lifetime as UkmService.
194 base::WeakPtrFactory<UkmService> self_ptr_factory_; 201 base::WeakPtrFactory<UkmService> self_ptr_factory_;
195 202
196 DISALLOW_COPY_AND_ASSIGN(UkmService); 203 DISALLOW_COPY_AND_ASSIGN(UkmService);
197 }; 204 };
198 205
199 } // namespace ukm 206 } // namespace ukm
200 207
201 #endif // COMPONENTS_UKM_UKM_SERVICE_H_ 208 #endif // COMPONENTS_UKM_UKM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698