File: study_filtering.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 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 (128 lines) | stat: -rw-r--r-- 5,092 bytes parent folder | download | duplicates (11)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Copyright 2014 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_STUDY_FILTERING_H_
#define COMPONENTS_VARIATIONS_STUDY_FILTERING_H_

#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "base/component_export.h"
#include "base/time/time.h"
#include "base/version.h"
#include "components/variations/client_filterable_state.h"
#include "components/variations/processed_study.h"
#include "components/variations/proto/study.pb.h"
#include "components/variations/proto/variations_seed.pb.h"
#include "components/variations/variations_layers.h"

namespace variations {

struct ClientFilterableState;

// Internal functions exposed for testing purposes only.
namespace internal {

// Checks whether a study is applicable for the given |channel| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyChannel(const Study::Filter& filter, Study::Channel channel);

// Checks whether a study is applicable for the given |form_factor| per
// |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyFormFactor(const Study::Filter& filter,
                          Study::FormFactor form_factor);

// Checks whether a study is applicable for the given |hardware_class| per
// |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyHardwareClass(const Study::Filter& filter,
                             const std::string& hardware_class);

// Checks whether a study is applicable for the given |locale| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyLocale(const Study::Filter& filter, const std::string& locale);

// Checks whether a study is applicable for the given |country| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyCountry(const Study::Filter& filter, const std::string& country);

// Checks whether a study is applicable for the given |platform| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyPlatform(const Study::Filter& filter, Study::Platform platform);

// Checks whether a study is applicable given |is_low_end_device| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyLowEndDevice(const Study::Filter& filter,
                            bool is_low_end_device);

// Checks whether a study is applicable given the ChromeVariations policy value.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyPolicyRestriction(const Study::Filter& filter,
                                 RestrictionPolicy policy_restriction);

// Checks whether a study is applicable for the given date/time per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyStartDate(const Study::Filter& filter,
                         const base::Time& date_time);

// Checks whether a study is applicable for the given date/time per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyEndDate(const Study::Filter& filter,
                       const base::Time& date_time);

// Checks whether a study is applicable for the given version per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyVersion(const Study::Filter& filter,
                       const base::Version& version);

// Checks whether a study is applicable for the given OS version per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyOSVersion(const Study::Filter& filter,
                         const base::Version& os_version);

// Checks whether a study is applicable given |is_enterprise| per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyEnterprise(const Study::Filter& filter,
                          const ClientFilterableState& client_state);

// Checks whether a study is applicable for the given Google group memberships
// per |filter|.
COMPONENT_EXPORT(VARIATIONS)
bool CheckStudyGoogleGroup(const Study::Filter& filter,
                           const ClientFilterableState& client_state);

// Returns the country that should be used for filtering this study, depending
// on whether the study has session or permanent consistency.
COMPONENT_EXPORT(VARIATIONS)
const std::string& GetClientCountryForStudy(
    const Study& study,
    const ClientFilterableState& client_state);

// Checks whether |study| is expired using the given date/time.
COMPONENT_EXPORT(VARIATIONS)
bool IsStudyExpired(const Study& study, const base::Time& date_time);

// Returns whether |study| should be disabled according to the restriction
// parameters in the |config|.
COMPONENT_EXPORT(VARIATIONS)
bool ShouldAddStudy(const ProcessedStudy& processed_study,
                    const ClientFilterableState& client_state,
                    const VariationsLayers& layers);

}  // namespace internal

// Validates and preprocesses studies in |seed|, filters them according to
// the |client_state| and |layers|, and ensures the result has at most one
// study with the same name.
COMPONENT_EXPORT(VARIATIONS)
std::vector<ProcessedStudy> FilterAndValidateStudies(
    const VariationsSeed& seed,
    const ClientFilterableState& client_state,
    const VariationsLayers& layers);

}  // namespace variations

#endif  // COMPONENTS_VARIATIONS_STUDY_FILTERING_H_