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

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

Issue 2612243003: Supporting study definitions without default groups and end_date filtering. (Closed)
Patch Set: removing static initializer Created 3 years, 11 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const base::Time& date_time) { 136 const base::Time& date_time) {
137 if (filter.has_start_date()) { 137 if (filter.has_start_date()) {
138 const base::Time start_date = 138 const base::Time start_date =
139 ConvertStudyDateToBaseTime(filter.start_date()); 139 ConvertStudyDateToBaseTime(filter.start_date());
140 return date_time >= start_date; 140 return date_time >= start_date;
141 } 141 }
142 142
143 return true; 143 return true;
144 } 144 }
145 145
146 bool CheckStudyEndDate(const Study_Filter& filter,
147 const base::Time& date_time) {
148 if (filter.has_end_date()) {
149 const base::Time end_date = ConvertStudyDateToBaseTime(filter.end_date());
150 return end_date >= date_time;
151 }
152
153 return true;
154 }
155
146 bool CheckStudyVersion(const Study_Filter& filter, 156 bool CheckStudyVersion(const Study_Filter& filter,
147 const base::Version& version) { 157 const base::Version& version) {
148 if (filter.has_min_version()) { 158 if (filter.has_min_version()) {
149 if (version.CompareToWildcardString(filter.min_version()) < 0) 159 if (version.CompareToWildcardString(filter.min_version()) < 0)
150 return false; 160 return false;
151 } 161 }
152 162
153 if (filter.has_max_version()) { 163 if (filter.has_max_version()) {
154 if (version.CompareToWildcardString(filter.max_version()) > 0) 164 if (version.CompareToWildcardString(filter.max_version()) > 0)
155 return false; 165 return false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DVLOG(1) << "Filtered out study " << study.name() << " due to version."; 228 DVLOG(1) << "Filtered out study " << study.name() << " due to version.";
219 return false; 229 return false;
220 } 230 }
221 231
222 if (!CheckStudyStartDate(study.filter(), reference_date)) { 232 if (!CheckStudyStartDate(study.filter(), reference_date)) {
223 DVLOG(1) << "Filtered out study " << study.name() << 233 DVLOG(1) << "Filtered out study " << study.name() <<
224 " due to start date."; 234 " due to start date.";
225 return false; 235 return false;
226 } 236 }
227 237
238 if (!CheckStudyEndDate(study.filter(), reference_date)) {
239 DVLOG(1) << "Filtered out study " << study.name() << " due to end date.";
240 return false;
241 }
242
228 if (!CheckStudyHardwareClass(study.filter(), hardware_class)) { 243 if (!CheckStudyHardwareClass(study.filter(), hardware_class)) {
229 DVLOG(1) << "Filtered out study " << study.name() << 244 DVLOG(1) << "Filtered out study " << study.name() <<
230 " due to hardware_class."; 245 " due to hardware_class.";
231 return false; 246 return false;
232 } 247 }
233 248
234 if (!CheckStudyCountry(study.filter(), country)) { 249 if (!CheckStudyCountry(study.filter(), country)) {
235 DVLOG(1) << "Filtered out study " << study.name() << " due to country."; 250 DVLOG(1) << "Filtered out study " << study.name() << " due to country.";
236 return false; 251 return false;
237 } 252 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 314
300 for (size_t i = 0; i < expired_studies.size(); ++i) { 315 for (size_t i = 0; i < expired_studies.size(); ++i) {
301 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) { 316 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) {
302 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true, 317 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true,
303 filtered_studies); 318 filtered_studies);
304 } 319 }
305 } 320 }
306 } 321 }
307 322
308 } // namespace variations 323 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/study_filtering.h ('k') | components/variations/study_filtering_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698