1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/metrics/debug/structured/structured_metrics_watcher.h" 6 7 #include "base/logging.h" 8 #include "components/metrics/structured/structured_metrics_service.h" 9 10 namespace metrics::structured { 11 StructuredMetricsWatcher(StructuredMetricsService * service)12StructuredMetricsWatcher::StructuredMetricsWatcher( 13 StructuredMetricsService* service) 14 : service_(service) { 15 Recorder::GetInstance()->AddObserver(this); 16 } 17 ~StructuredMetricsWatcher()18StructuredMetricsWatcher::~StructuredMetricsWatcher() { 19 Recorder::GetInstance()->RemoveObserver(this); 20 } 21 OnEventRecord(const Event & event)22void StructuredMetricsWatcher::OnEventRecord(const Event& event) { 23 if (!service_->recording_enabled()) { 24 return; 25 } 26 27 events_.push_back(event.Clone()); 28 } 29 OnProfileAdded(const base::FilePath & profile_path)30void StructuredMetricsWatcher::OnProfileAdded( 31 const base::FilePath& profile_path) { 32 /* Do nothing */ 33 } 34 OnReportingStateChanged(bool enabled)35void StructuredMetricsWatcher::OnReportingStateChanged(bool enabled) { 36 /* Do nothing */ 37 } 38 39 } // namespace metrics::structured 40