OLD | NEW |
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 <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 const char kRulesetFlavorParameterName[] = "ruleset_flavor"; | 146 const char kRulesetFlavorParameterName[] = "ruleset_flavor"; |
147 | 147 |
148 const char kPerformanceMeasurementRateParameterName[] = | 148 const char kPerformanceMeasurementRateParameterName[] = |
149 "performance_measurement_rate"; | 149 "performance_measurement_rate"; |
150 | 150 |
151 const char kSuppressNotificationsParameterName[] = "suppress_notifications"; | 151 const char kSuppressNotificationsParameterName[] = "suppress_notifications"; |
152 | 152 |
153 const char kWhitelistSiteOnReloadParameterName[] = "whitelist_site_on_reload"; | 153 const char kWhitelistSiteOnReloadParameterName[] = "whitelist_site_on_reload"; |
154 | 154 |
155 Configuration::Configuration() = default; | 155 Configuration::Configuration() = default; |
| 156 Configuration::Configuration(ActivationLevel activation_level, |
| 157 ActivationScope activation_scope, |
| 158 ActivationList activation_list) |
| 159 : activation_level(activation_level), |
| 160 activation_scope(activation_scope), |
| 161 activation_list(activation_list) {} |
| 162 Configuration::Configuration(Configuration&&) = default; |
156 Configuration::~Configuration() = default; | 163 Configuration::~Configuration() = default; |
157 Configuration::Configuration(Configuration&&) = default; | |
158 Configuration& Configuration::operator=(Configuration&&) = default; | 164 Configuration& Configuration::operator=(Configuration&&) = default; |
159 | 165 |
160 ConfigurationList::ConfigurationList(Configuration config) | 166 ConfigurationList::ConfigurationList(Configuration config) |
161 : config_(std::move(config)) {} | 167 : config_(std::move(config)) {} |
162 ConfigurationList::~ConfigurationList() = default; | 168 ConfigurationList::~ConfigurationList() = default; |
163 | 169 |
164 scoped_refptr<ConfigurationList> GetActiveConfigurations() { | 170 scoped_refptr<ConfigurationList> GetActiveConfigurations() { |
165 base::AutoLock lock(g_active_configurations_lock.Get()); | 171 base::AutoLock lock(g_active_configurations_lock.Get()); |
166 if (!g_active_configurations.Get()) { | 172 if (!g_active_configurations.Get()) { |
167 g_active_configurations.Get() = | 173 g_active_configurations.Get() = |
168 base::MakeShared<ConfigurationList>(ParseFieldTrialConfiguration()); | 174 base::MakeShared<ConfigurationList>(ParseFieldTrialConfiguration()); |
169 } | 175 } |
170 return g_active_configurations.Get(); | 176 return g_active_configurations.Get(); |
171 } | 177 } |
172 | 178 |
173 namespace testing { | 179 namespace testing { |
174 | 180 |
175 void ClearCachedActiveConfigurations() { | 181 scoped_refptr<ConfigurationList> GetAndSetActivateConfigurations( |
| 182 scoped_refptr<ConfigurationList> new_configs) { |
176 base::AutoLock lock(g_active_configurations_lock.Get()); | 183 base::AutoLock lock(g_active_configurations_lock.Get()); |
177 g_active_configurations.Get() = nullptr; | 184 auto old_configs = std::move(g_active_configurations.Get()); |
| 185 g_active_configurations.Get() = std::move(new_configs); |
| 186 return old_configs; |
178 } | 187 } |
179 | 188 |
180 } // namespace testing | 189 } // namespace testing |
181 | 190 |
182 } // namespace subresource_filter | 191 } // namespace subresource_filter |
OLD | NEW |