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

Side by Side Diff: components/variations/study_filtering.cc

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/variations/study_filtering.h" 5 #include "components/variations/study_filtering.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 bool CheckStudyCountry(const Study_Filter& filter, const std::string& country) { 158 bool CheckStudyCountry(const Study_Filter& filter, const std::string& country) {
159 // Empty country and exclude_country matches all. 159 // Empty country and exclude_country matches all.
160 if (filter.country_size() == 0 && filter.exclude_country_size() == 0) 160 if (filter.country_size() == 0 && filter.exclude_country_size() == 0)
161 return true; 161 return true;
162 162
163 // Checks if we are supposed to filter for a specified set of countries. Note 163 // Checks if we are supposed to filter for a specified set of countries. Note
164 // that this means this overrides the exclude_country in case that ever occurs 164 // that this means this overrides the exclude_country in case that ever occurs
165 // (which it shouldn't). 165 // (which it shouldn't).
166 if (filter.country_size() > 0) 166 if (filter.country_size() > 0)
167 return ContainsValue(filter.country(), country); 167 return base::ContainsValue(filter.country(), country);
168 168
169 // Omit if matches any of the exclude entries. 169 // Omit if matches any of the exclude entries.
170 return !ContainsValue(filter.exclude_country(), country); 170 return !base::ContainsValue(filter.exclude_country(), country);
171 } 171 }
172 172
173 bool IsStudyExpired(const Study& study, const base::Time& date_time) { 173 bool IsStudyExpired(const Study& study, const base::Time& date_time) {
174 if (study.has_expiry_date()) { 174 if (study.has_expiry_date()) {
175 const base::Time expiry_date = 175 const base::Time expiry_date =
176 ConvertStudyDateToBaseTime(study.expiry_date()); 176 ConvertStudyDateToBaseTime(study.expiry_date());
177 return date_time >= expiry_date; 177 return date_time >= expiry_date;
178 } 178 }
179 179
180 return false; 180 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 if (!internal::ShouldAddStudy(study, locale, reference_date, version, 283 if (!internal::ShouldAddStudy(study, locale, reference_date, version,
284 channel, form_factor, hardware_class, 284 channel, form_factor, hardware_class,
285 country)) { 285 country)) {
286 continue; 286 continue;
287 } 287 }
288 288
289 if (internal::IsStudyExpired(study, reference_date)) { 289 if (internal::IsStudyExpired(study, reference_date)) {
290 expired_studies.push_back(&study); 290 expired_studies.push_back(&study);
291 } else if (!ContainsKey(created_studies, study.name())) { 291 } else if (!base::ContainsKey(created_studies, study.name())) {
292 ProcessedStudy::ValidateAndAppendStudy(&study, false, filtered_studies); 292 ProcessedStudy::ValidateAndAppendStudy(&study, false, filtered_studies);
293 created_studies.insert(study.name()); 293 created_studies.insert(study.name());
294 } 294 }
295 } 295 }
296 296
297 for (size_t i = 0; i < expired_studies.size(); ++i) { 297 for (size_t i = 0; i < expired_studies.size(); ++i) {
298 if (!ContainsKey(created_studies, expired_studies[i]->name())) { 298 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) {
299 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true, 299 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true,
300 filtered_studies); 300 filtered_studies);
301 } 301 }
302 } 302 }
303 } 303 }
304 304
305 } // namespace variations 305 } // namespace variations
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/segregated_pref_store.cc ('k') | components/variations/variations_associated_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698