Index: components/ukm/ukm_service.h |
diff --git a/components/ukm/ukm_service.h b/components/ukm/ukm_service.h |
index 9ffd417d54bbc5b6ae8ba505987118ae25679bec..d154c7ce1f9b43fba5a2bd05a3baea232e9fbd0c 100644 |
--- a/components/ukm/ukm_service.h |
+++ b/components/ukm/ukm_service.h |
@@ -26,6 +26,8 @@ class MetricsServiceClient; |
namespace ukm { |
+class UkmSource; |
+ |
// This feature controls whether UkmService should be created. |
extern const base::Feature kUkmFeature; |
@@ -48,6 +50,10 @@ class UkmService : public base::SupportsWeakPtr<UkmService> { |
void EnableReporting(); |
void DisableReporting(); |
+ // Adds a new source of UKM metrics, which will be stored |
+ // until periodically serialized for upload, and then deleted. |
+ void RecordSource(std::unique_ptr<UkmSource> source); |
+ |
// Record any collected data into logs, and write to disk. |
void Flush(); |
@@ -58,6 +64,11 @@ class UkmService : public base::SupportsWeakPtr<UkmService> { |
// the provided PrefRegistry. |
static void RegisterPrefs(PrefRegistrySimple* registry); |
+ protected: |
+ const std::vector<std::unique_ptr<UkmSource>>& sources_for_testing() const { |
+ return sources_; |
+ } |
+ |
private: |
// Start metrics client initialization. |
void StartInitTask(); |
@@ -104,6 +115,10 @@ class UkmService : public base::SupportsWeakPtr<UkmService> { |
bool initialize_complete_; |
bool log_upload_in_progress_; |
+ // Contains newly added sources of UKM metrics which periodically |
+ // get serialized and cleared by BuildAndStoreLog(). |
+ std::vector<std::unique_ptr<UkmSource>> sources_; |
+ |
// Weak pointers factory used to post task on different threads. All weak |
// pointers managed by this factory have the same lifetime as UkmService. |
base::WeakPtrFactory<UkmService> self_ptr_factory_; |