File: field_trial_list_including_low_anonymity.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (98 lines) | stat: -rw-r--r-- 3,648 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_METRICS_FIELD_TRIAL_LIST_INCLUDING_LOW_ANONYMITY_H_
#define BASE_METRICS_FIELD_TRIAL_LIST_INCLUDING_LOW_ANONYMITY_H_

#include "base/gtest_prod_util.h"
#include "base/metrics/field_trial.h"
#include "base/values.h"

class AndroidFieldTrialListLogActiveTrialsFriendHelper;

namespace content {
class FieldTrialSynchronizer;
}

namespace variations {
class ChildProcessFieldTrialSyncer;
class EntropyProviders;
class ProcessedStudy;
struct SeedSimulationResult;
class VariationsCrashKeys;
class VariationsLayers;
SeedSimulationResult ComputeDifferences(
    const std::vector<ProcessedStudy>& processed_studies,
    const VariationsLayers& layers,
    const EntropyProviders& entropy_providers);
}  // namespace variations

namespace version_ui {
base::Value::List GetVariationsList();
}

namespace base {

// Provides a way to restrict access to the full set of field trials, including
// trials with low anonymity, to explicitly allowed callers.
//
// See |FieldTrialList::FactoryGetFieldTrial()| for background.
class BASE_EXPORT FieldTrialListIncludingLowAnonymity {
 public:
  // Exposed publicly, to avoid test code needing to be explicitly friended.
  static void GetActiveFieldTrialGroupsForTesting(
      FieldTrial::ActiveGroups* active_groups) {
    return GetActiveFieldTrialGroups(active_groups);
  }

  // Classes / functions which are allowed full access to all field trials
  // should be listed as friends here, with a comment explaining why this does
  // not risk revealing identifiable information externally.

  // This is used only for local logging on Android.
  friend class ::AndroidFieldTrialListLogActiveTrialsFriendHelper;

  // Used to synchronize field trial status between the browser and child
  // processes.
  // Access to these trials within each of these is then allowed only to the
  // other friend classes / methods listed here.
  friend class content::FieldTrialSynchronizer;
  friend class variations::ChildProcessFieldTrialSyncer;

  // This is only used to simulate seed changes, not sent to Google servers.
  friend variations::SeedSimulationResult variations::ComputeDifferences(
      const std::vector<variations::ProcessedStudy>& processed_studies,
      const variations::VariationsLayers& layers,
      const variations::EntropyProviders& entropy_providers);

  // Include all active field trials in crash reports, so that crashes are
  // reproducible: https://www.google.com/intl/en/chrome/privacy/.
  friend class variations::VariationsCrashKeys;

  // This usage is to display field trials in chrome://version and other local
  // internal UIs.
  friend base::Value::List version_ui::GetVariationsList();

  // Required for tests.
  friend class TestFieldTrialObserverIncludingLowAnonymity;
  FRIEND_TEST_ALL_PREFIXES(FieldTrialTest, ObserveIncludingLowAnonymity);

 private:
  // The same as |FieldTrialList::GetActiveFieldTrialGroups| but gives access to
  // low anonymity field trials too.
  static void GetActiveFieldTrialGroups(
      FieldTrial::ActiveGroups* active_groups);

  // Identical to |FieldTrialList::AddObserver| but also notifies of low
  // anonymity trials.
  static bool AddObserver(FieldTrialList::Observer* observer);

  // Identical to |FieldTrialList::RemoveObserver| but for observers registered
  // through the AddObserver() function of this class.
  static void RemoveObserver(FieldTrialList::Observer* observer);
};

}  // namespace base

#endif  // BASE_METRICS_FIELD_TRIAL_LIST_INCLUDING_LOW_ANONYMITY_H_