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

Side by Side Diff: components/subresource_filter/core/browser/subresource_filter_features.h

Issue 2875033004: [subresource_filter] Add debugging trace events around activation (Closed)
Patch Set: quick fix Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H _ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H _
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H _ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURES_H _
7 7
8 #include <iosfwd> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "components/subresource_filter/core/common/activation_level.h" 15 #include "components/subresource_filter/core/common/activation_level.h"
16 #include "components/subresource_filter/core/common/activation_list.h" 16 #include "components/subresource_filter/core/common/activation_list.h"
17 #include "components/subresource_filter/core/common/activation_scope.h" 17 #include "components/subresource_filter/core/common/activation_scope.h"
18 18
19 namespace base {
20 namespace trace_event {
21 class TracedValue;
22 } // namespace trace_event
23 } // namespace base
24
19 namespace subresource_filter { 25 namespace subresource_filter {
20 26
21 // Encapsulates a set of parameters that define how the subresource filter 27 // Encapsulates a set of parameters that define how the subresource filter
22 // feature should operate. Each configuration consists of three parts as 28 // feature should operate. Each configuration consists of three parts as
23 // described in detail below. 29 // described in detail below.
24 // 30 //
25 // There can be multiple configuration enabled at the same time. For each 31 // There can be multiple configuration enabled at the same time. For each
26 // navigation, however, subresource filtering will be activated according to 32 // navigation, however, subresource filtering will be activated according to
27 // exactly one of these enabled configuration, if any. Namely, the configuration 33 // exactly one of these enabled configuration, if any. Namely, the configuration
28 // with the highest |priority| among those whose |activation_conditions| are 34 // with the highest |priority| among those whose |activation_conditions| are
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 ActivationList activation_list = ActivationList::NONE); 101 ActivationList activation_list = ActivationList::NONE);
96 Configuration(const Configuration&); 102 Configuration(const Configuration&);
97 Configuration(Configuration&&); 103 Configuration(Configuration&&);
98 ~Configuration(); 104 ~Configuration();
99 Configuration& operator=(const Configuration&); 105 Configuration& operator=(const Configuration&);
100 Configuration& operator=(Configuration&&); 106 Configuration& operator=(Configuration&&);
101 107
102 bool operator==(const Configuration& rhs) const; 108 bool operator==(const Configuration& rhs) const;
103 bool operator!=(const Configuration& rhs) const; 109 bool operator!=(const Configuration& rhs) const;
104 110
111 std::unique_ptr<base::trace_event::TracedValue> ToTracedValue() const;
112
105 // Factory methods for preset configurations. 113 // Factory methods for preset configurations.
106 // 114 //
107 // To add a new preset: 115 // To add a new preset:
108 // 1.) Define a named factory method here. 116 // 1.) Define a named factory method here.
109 // 2.) Define a name for the configuration to be used in variation params. 117 // 2.) Define a name for the configuration to be used in variation params.
110 // 3.) Register it into |kAvailablePresetConfigurations| in the .cc file. 118 // 3.) Register it into |kAvailablePresetConfigurations| in the .cc file.
111 // 4.) Update unittests to cover the new preset. 119 // 4.) Update unittests to cover the new preset.
112 static Configuration MakePresetForLiveRunOnPhishingSites(); 120 static Configuration MakePresetForLiveRunOnPhishingSites();
113 static Configuration MakePresetForPerformanceTestingDryRunOnAllSites(); 121 static Configuration MakePresetForPerformanceTestingDryRunOnAllSites();
114 122
115 ActivationConditions activation_conditions; 123 ActivationConditions activation_conditions;
116 ActivationOptions activation_options; 124 ActivationOptions activation_options;
117 GeneralSettings general_settings; 125 GeneralSettings general_settings;
118 }; 126 };
119 127
120 // For logging in tests.
121 std::ostream& operator<<(std::ostream& os, const Configuration& config);
122
123 // Thread-safe, ref-counted wrapper around an immutable list of configurations. 128 // Thread-safe, ref-counted wrapper around an immutable list of configurations.
124 class ConfigurationList : public base::RefCountedThreadSafe<ConfigurationList> { 129 class ConfigurationList : public base::RefCountedThreadSafe<ConfigurationList> {
125 public: 130 public:
126 explicit ConfigurationList(std::vector<Configuration> configs); 131 explicit ConfigurationList(std::vector<Configuration> configs);
127 132
128 // Returns the lexicographically greatest flavor string that is prescribed by 133 // Returns the lexicographically greatest flavor string that is prescribed by
129 // any of the configurations. The caller must hold a reference to this 134 // any of the configurations. The caller must hold a reference to this
130 // instance while using the returned string piece. 135 // instance while using the returned string piece.
131 base::StringPiece lexicographically_greatest_ruleset_flavor() const { 136 base::StringPiece lexicographically_greatest_ruleset_flavor() const {
132 return lexicographically_greatest_ruleset_flavor_; 137 return lexicographically_greatest_ruleset_flavor_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 extern const char kRulesetFlavorParameterName[]; 204 extern const char kRulesetFlavorParameterName[];
200 205
201 extern const char kEnablePresetsParameterName[]; 206 extern const char kEnablePresetsParameterName[];
202 extern const char kDisablePresetsParameterName[]; 207 extern const char kDisablePresetsParameterName[];
203 extern const char kPresetLiveRunOnPhishingSites[]; 208 extern const char kPresetLiveRunOnPhishingSites[];
204 extern const char kPresetPerformanceTestingDryRunOnAllSites[]; 209 extern const char kPresetPerformanceTestingDryRunOnAllSites[];
205 210
206 } // namespace subresource_filter 211 } // namespace subresource_filter
207 212
208 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE S_H_ 213 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_BROWSER_SUBRESOURCE_FILTER_FEATURE S_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698