File: variations_crash_keys.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (69 lines) | stat: -rw-r--r-- 2,833 bytes parent folder | download | duplicates (5)
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
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VARIATIONS_VARIATIONS_CRASH_KEYS_H_
#define COMPONENTS_VARIATIONS_VARIATIONS_CRASH_KEYS_H_

#include <string>
#include <vector>

#include "base/component_export.h"

namespace variations {

class SyntheticTrialGroup;
struct ActiveGroupId;

// The key used in crash reports to indicate the number of active experiments.
// Should match the number of entries in kExperimentListKey.
COMPONENT_EXPORT(VARIATIONS) extern const char kNumExperimentsKey[];

// The key used in crash reports to list all the active experiments. Each
// experiment is listed as two hex numbers: trial ID and group ID, separated by
// a dash. The experiments are separated by a comma.
COMPONENT_EXPORT(VARIATIONS) extern const char kExperimentListKey[];

COMPONENT_EXPORT(VARIATIONS) extern const char kVariationsSeedVersionKey[];

// Initializes crash keys that report the current set of active FieldTrial
// groups (aka variations) for crash reports. After initialization, an observer
// will be registered on FieldTrialList that will keep the crash keys up-to-date
// with newly-activated trials. Synthetic trials must be manually updated using
// the API below.
COMPONENT_EXPORT(VARIATIONS) void InitCrashKeys();

// Updates variations crash keys by replacing the list of synthetic trials with
// the specified list. Does not affect non-synthetic trials.
COMPONENT_EXPORT(VARIATIONS)
void UpdateCrashKeysWithSyntheticTrials(
    const std::vector<SyntheticTrialGroup>& synthetic_trials);

// Sets the crash key for the variations seed version.
COMPONENT_EXPORT(VARIATIONS)
void SetVariationsSeedVersionCrashKey(const std::string& seed_version);

// Clears the internal instance, for testing.
COMPONENT_EXPORT(VARIATIONS) void ClearCrashKeysInstanceForTesting();

// The list of experiments, in the format needed by the crash keys. The
// |num_experiments| goes into the |kNumExperimentsKey| crash key, and the
// |experiment_list| goes into the |kExperimentListKey| crash key.
struct COMPONENT_EXPORT(VARIATIONS) ExperimentListInfo {
  int num_experiments = 0;
  std::string experiment_list;
};

// Gets the variation information that we encode in the crash keys.
// Specifically, returns the string used for representing the active experiment
// groups + the synthetic trials in |experiment_list| and the number of elements
// in that list in |num_experiments|. Must be called on the UI thread.
COMPONENT_EXPORT(VARIATIONS) ExperimentListInfo GetExperimentListInfo();

// Gets the hash code of the experiment.
COMPONENT_EXPORT(VARIATIONS)
std::string ActiveGroupToString(const ActiveGroupId& active_group);

}  // namespace variations

#endif  // COMPONENTS_VARIATIONS_VARIATIONS_CRASH_KEYS_H_