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

Unified Diff: components/metrics/metrics_service.h

Issue 688973004: Plumbing for variations headers from synthetic field trials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expose another hashed API in variations_associated_data.h Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/metrics_service.h
diff --git a/components/metrics/metrics_service.h b/components/metrics/metrics_service.h
index eae44f3cf4dc36a02c66fd1dbf90d0421f4853ec..19794ea47a1d455ba858080a2d7d7117b854d5d4 100644
--- a/components/metrics/metrics_service.h
+++ b/components/metrics/metrics_service.h
@@ -21,6 +21,7 @@
#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_snapshot_manager.h"
#include "base/metrics/user_metrics.h"
+#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/metrics/clean_exit_beacon.h"
#include "components/metrics/metrics_log.h"
@@ -76,6 +77,17 @@ struct SyntheticTrialGroup {
SyntheticTrialGroup(uint32 trial, uint32 group);
};
+// Interface class to observe changes to synthetic trials in MetricsService.
+class SyntheticTrialObserver {
+ public:
+ // Called when the list of synthetic field trial groups has changed.
+ virtual void OnSyntheticTrialsChanged(
+ const std::vector<SyntheticTrialGroup>& groups) = 0;
+
+ protected:
+ virtual ~SyntheticTrialObserver() {}
+};
+
// See metrics_service.cc for a detailed description.
class MetricsService : public base::HistogramFlattener {
public:
@@ -211,6 +223,12 @@ class MetricsService : public base::HistogramFlattener {
// To use this method, SyntheticTrialGroup should friend your class.
void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group);
+ // Adds an observer to be notified when the synthetic trials list changes.
+ void AddSyntheticTrialObserver(SyntheticTrialObserver* observer);
+
+ // Removes an existing observer of synthetic trials list changes.
+ void RemoveSyntheticTrialObserver(SyntheticTrialObserver* observer);
+
// Register the specified |provider| to provide additional metrics into the
// UMA log. Should be called during MetricsService initialization only.
void RegisterMetricsProvider(scoped_ptr<MetricsProvider> provider);
@@ -358,6 +376,9 @@ class MetricsService : public base::HistogramFlattener {
// Sets the value of the specified path in prefs and schedules a save.
void RecordBooleanPrefValue(const char* path, bool value);
+ // Notifies observers on a synthetic trial list change.
+ void NotifySyntheticTrialObservers();
+
// Returns a list of synthetic field trials that were active for the entire
// duration of the current log.
void GetCurrentSyntheticFieldTrials(
@@ -447,6 +468,9 @@ class MetricsService : public base::HistogramFlattener {
// Field trial groups that map to Chrome configuration states.
SyntheticTrialGroups synthetic_trial_groups_;
+ // List of observers of |synthetic_trial_groups_| changes.
+ ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_;
+
// Execution phase the browser is in.
static ExecutionPhase execution_phase_;

Powered by Google App Engine
This is Rietveld 408576698