[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / metrics / field_trials_provider.h
1 // Copyright 2017 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 #ifndef COMPONENTS_METRICS_FIELD_TRIALS_PROVIDER_H_
6 #define COMPONENTS_METRICS_FIELD_TRIALS_PROVIDER_H_
7
8 #include "base/memory/raw_ptr.h"
9 #include "base/strings/string_piece.h"
10 #include "base/time/time.h"
11 #include "components/metrics/metrics_provider.h"
12 #include "third_party/metrics_proto/chrome_user_metrics_extension.pb.h"
13
14 // TODO(crbug/507665): Once MetricsProvider/SystemProfileProto are moved into
15 // //services/metrics, then //components/variations can depend on them, and
16 // this should be moved there.
17 namespace variations {
18
19 class SyntheticTrialRegistry;
20 struct ActiveGroupId;
21
22 class FieldTrialsProvider : public metrics::MetricsProvider {
23  public:
24   // |registry| must outlive this metrics provider.
25   FieldTrialsProvider(SyntheticTrialRegistry* registry,
26                       base::StringPiece suffix);
27
28   FieldTrialsProvider(const FieldTrialsProvider&) = delete;
29   FieldTrialsProvider& operator=(const FieldTrialsProvider&) = delete;
30
31   ~FieldTrialsProvider() override;
32
33   // metrics::MetricsProvider:
34   void ProvideSystemProfileMetrics(
35       metrics::SystemProfileProto* system_profile_proto) override;
36   void ProvideSystemProfileMetricsWithLogCreationTime(
37       base::TimeTicks log_creation_time,
38       metrics::SystemProfileProto* system_profile_proto) override;
39   void ProvideCurrentSessionData(
40       metrics::ChromeUserMetricsExtension* uma_proto) override;
41
42   // Sets |log_creation_time_| to |time|.
43   void SetLogCreationTimeForTesting(base::TimeTicks time);
44
45  private:
46   // Populates |field_trial_ids| with currently active field trials groups. The
47   // trial and group names are suffixed with |suffix_| before being hashed.
48   void GetFieldTrialIds(std::vector<ActiveGroupId>* field_trial_ids) const;
49
50   // Gets active FieldTrials and SyntheticFieldTrials and populates
51   // |system_profile_proto| with them.
52   void GetAndWriteFieldTrials(
53       metrics::SystemProfileProto* system_profile_proto) const;
54
55   // The most recent time passed to
56   // ProvideSystemProfileMetricsWithLogCreationTime().
57   base::TimeTicks log_creation_time_;
58
59   raw_ptr<SyntheticTrialRegistry> registry_;
60
61   // Suffix used for the field trial names before they are hashed for uploads.
62   std::string suffix_;
63 };
64
65 }  // namespace variations
66
67 #endif  // COMPONENTS_METRICS_FIELD_TRIALS_PROVIDER_H_