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

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

Issue 2894523006: Add instrumentation hooks to mesaure which subresource filter rules are used.
Patch Set: 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 #include "components/subresource_filter/core/browser/subresource_filter_features .h" 5 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
6 6
7 #include <map> 7 #include <map>
8 #include <ostream> 8 #include <ostream>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 std::vector<Configuration> FillEnabledPresetConfigurations( 115 std::vector<Configuration> FillEnabledPresetConfigurations(
116 std::map<std::string, std::string>* params) { 116 std::map<std::string, std::string>* params) {
117 const struct { 117 const struct {
118 const char* name; 118 const char* name;
119 bool enabled_by_default; 119 bool enabled_by_default;
120 Configuration (*factory_method)(); 120 Configuration (*factory_method)();
121 } kAvailablePresetConfigurations[] = { 121 } kAvailablePresetConfigurations[] = {
122 {kPresetLiveRunOnPhishingSites, false, 122 {kPresetLiveRunOnPhishingSites, false,
123 &Configuration::MakePresetForLiveRunOnPhishingSites}, 123 &Configuration::MakePresetForLiveRunOnPhishingSites},
124 {kPresetPerformanceTestingDryRunOnAllSites, false, 124 {kPresetPerformanceTestingDryRunOnAllSites, true,
125 &Configuration::MakePresetForPerformanceTestingDryRunOnAllSites}}; 125 &Configuration::MakePresetForPerformanceTestingDryRunOnAllSites}};
126 126
127 CommaSeparatedStrings enabled_presets( 127 CommaSeparatedStrings enabled_presets(
128 TakeVariationParamOrReturnEmpty(params, kEnablePresetsParameterName)); 128 TakeVariationParamOrReturnEmpty(params, kEnablePresetsParameterName));
129 CommaSeparatedStrings disabled_presets( 129 CommaSeparatedStrings disabled_presets(
130 TakeVariationParamOrReturnEmpty(params, kDisablePresetsParameterName)); 130 TakeVariationParamOrReturnEmpty(params, kDisablePresetsParameterName));
131 131
132 std::vector<Configuration> enabled_configurations; 132 std::vector<Configuration> enabled_configurations;
133 for (const auto& available_preset : kAvailablePresetConfigurations) { 133 for (const auto& available_preset : kAvailablePresetConfigurations) {
134 if ((enabled_presets.CaseInsensitiveContains(available_preset.name) || 134 if ((enabled_presets.CaseInsensitiveContains(available_preset.name) ||
135 available_preset.enabled_by_default) && 135 available_preset.enabled_by_default) &&
136 !disabled_presets.CaseInsensitiveContains(available_preset.name)) { 136 !disabled_presets.CaseInsensitiveContains(available_preset.name)) {
137 enabled_configurations.push_back(available_preset.factory_method()); 137 enabled_configurations.push_back(available_preset.factory_method());
138 } 138 }
139 } 139 }
140 140
141 return enabled_configurations; 141 return enabled_configurations;
142 } 142 }
143 143
144 Configuration ParseExperimentalConfiguration( 144 Configuration ParseExperimentalConfiguration(
145 std::map<std::string, std::string>* params) { 145 std::map<std::string, std::string>* params) {
146 Configuration configuration; 146 Configuration configuration;
147 147
148 LOG(ERROR) << "ParseExperimentalConfigurations";
148 // ActivationConditions: 149 // ActivationConditions:
149 configuration.activation_conditions.activation_scope = ParseActivationScope( 150 configuration.activation_conditions.activation_scope = ParseActivationScope(
150 TakeVariationParamOrReturnEmpty(params, kActivationScopeParameterName)); 151 TakeVariationParamOrReturnEmpty(params, kActivationScopeParameterName));
151 152
152 configuration.activation_conditions.activation_list = ParseActivationList( 153 configuration.activation_conditions.activation_list = ParseActivationList(
153 TakeVariationParamOrReturnEmpty(params, kActivationListsParameterName)); 154 TakeVariationParamOrReturnEmpty(params, kActivationListsParameterName));
154 155
155 configuration.activation_conditions.priority = 156 configuration.activation_conditions.priority =
156 ParseInt(TakeVariationParamOrReturnEmpty( 157 ParseInt(TakeVariationParamOrReturnEmpty(
157 params, kActivationPriorityParameterName)); 158 params, kActivationPriorityParameterName));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 scoped_refptr<ConfigurationList> new_configs) { 368 scoped_refptr<ConfigurationList> new_configs) {
368 base::AutoLock lock(g_active_configurations_lock.Get()); 369 base::AutoLock lock(g_active_configurations_lock.Get());
369 auto old_configs = std::move(g_active_configurations.Get()); 370 auto old_configs = std::move(g_active_configurations.Get());
370 g_active_configurations.Get() = std::move(new_configs); 371 g_active_configurations.Get() = std::move(new_configs);
371 return old_configs; 372 return old_configs;
372 } 373 }
373 374
374 } // namespace testing 375 } // namespace testing
375 376
376 } // namespace subresource_filter 377 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698