| 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> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 friend UkmPageLoadMetricsObserver; | 112 friend UkmPageLoadMetricsObserver; |
| 113 friend autofill::AutofillMetrics; | 113 friend autofill::AutofillMetrics; |
| 114 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics); | 114 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, AddEntryOnlyWithNonEmptyMetrics); |
| 115 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); | 115 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, EntryBuilderAndSerialization); |
| 116 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, | 116 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, |
| 117 LogsUploadedOnlyWhenHavingSourcesOrEntries); | 117 LogsUploadedOnlyWhenHavingSourcesOrEntries); |
| 118 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); | 118 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, MetricsProviderTest); |
| 119 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); | 119 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, PersistAndPurge); |
| 120 FRIEND_TEST_ALL_PREFIXES(UkmServiceTest, WhitelistEntryTest); |
| 120 | 121 |
| 121 // Get a new UkmEntryBuilder object for the specified source ID and event, | 122 // Get a new UkmEntryBuilder object for the specified source ID and event, |
| 122 // which can get metrics added to. | 123 // which can get metrics added to. |
| 123 // | 124 // |
| 124 // This API being private is intentional. Any client using UKM needs to | 125 // This API being private is intentional. Any client using UKM needs to |
| 125 // declare itself to be a friend of UkmService and go through code review | 126 // declare itself to be a friend of UkmService and go through code review |
| 126 // process. | 127 // process. |
| 127 std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(int32_t source_id, | 128 std::unique_ptr<UkmEntryBuilder> GetEntryBuilder(int32_t source_id, |
| 128 const char* event_name); | 129 const char* event_name); |
| 129 | 130 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 | 144 |
| 144 // Starts an upload of the next log from persisted_logs_. | 145 // Starts an upload of the next log from persisted_logs_. |
| 145 void StartScheduledUpload(); | 146 void StartScheduledUpload(); |
| 146 | 147 |
| 147 // Called by log_uploader_ when the an upload is completed. | 148 // Called by log_uploader_ when the an upload is completed. |
| 148 void OnLogUploadComplete(int response_code); | 149 void OnLogUploadComplete(int response_code); |
| 149 | 150 |
| 150 // Add an entry to the UkmEntry list. | 151 // Add an entry to the UkmEntry list. |
| 151 void AddEntry(std::unique_ptr<UkmEntry> entry); | 152 void AddEntry(std::unique_ptr<UkmEntry> entry); |
| 152 | 153 |
| 154 // Cache the list of whitelisted entries from the field trial parameter. |
| 155 void StoreWhitelistedEntries(); |
| 156 |
| 153 // A weak pointer to the PrefService used to read and write preferences. | 157 // A weak pointer to the PrefService used to read and write preferences. |
| 154 PrefService* pref_service_; | 158 PrefService* pref_service_; |
| 155 | 159 |
| 156 // Whether recording new data is currently allowed. | 160 // Whether recording new data is currently allowed. |
| 157 bool recording_enabled_; | 161 bool recording_enabled_; |
| 158 | 162 |
| 159 // The UKM client id stored in prefs. | 163 // The UKM client id stored in prefs. |
| 160 uint64_t client_id_; | 164 uint64_t client_id_; |
| 161 | 165 |
| 162 // The UKM session id stored in prefs. | 166 // The UKM session id stored in prefs. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 182 | 186 |
| 183 bool initialize_started_; | 187 bool initialize_started_; |
| 184 bool initialize_complete_; | 188 bool initialize_complete_; |
| 185 bool log_upload_in_progress_; | 189 bool log_upload_in_progress_; |
| 186 | 190 |
| 187 // Contains newly added sources and entries of UKM metrics which periodically | 191 // Contains newly added sources and entries of UKM metrics which periodically |
| 188 // get serialized and cleared by BuildAndStoreLog(). | 192 // get serialized and cleared by BuildAndStoreLog(). |
| 189 std::map<int32_t, std::unique_ptr<UkmSource>> sources_; | 193 std::map<int32_t, 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_ |
| OLD | NEW |