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

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

Issue 2615763002: Revert of Supporting study definitions without default groups and end_date filtering. (Closed)
Patch Set: 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
156 bool CheckStudyVersion(const Study_Filter& filter, 146 bool CheckStudyVersion(const Study_Filter& filter,
157 const base::Version& version) { 147 const base::Version& version) {
158 if (filter.has_min_version()) { 148 if (filter.has_min_version()) {
159 if (version.CompareToWildcardString(filter.min_version()) < 0) 149 if (version.CompareToWildcardString(filter.min_version()) < 0)
160 return false; 150 return false;
161 } 151 }
162 152
163 if (filter.has_max_version()) { 153 if (filter.has_max_version()) {
164 if (version.CompareToWildcardString(filter.max_version()) > 0) 154 if (version.CompareToWildcardString(filter.max_version()) > 0)
165 return false; 155 return false;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 DVLOG(1) << "Filtered out study " << study.name() << " due to version."; 218 DVLOG(1) << "Filtered out study " << study.name() << " due to version.";
229 return false; 219 return false;
230 } 220 }
231 221
232 if (!CheckStudyStartDate(study.filter(), reference_date)) { 222 if (!CheckStudyStartDate(study.filter(), reference_date)) {
233 DVLOG(1) << "Filtered out study " << study.name() << 223 DVLOG(1) << "Filtered out study " << study.name() <<
234 " due to start date."; 224 " due to start date.";
235 return false; 225 return false;
236 } 226 }
237 227
238 if (!CheckStudyEndDate(study.filter(), reference_date)) {
239 DVLOG(1) << "Filtered out study " << study.name() << " due to end date.";
240 return false;
241 }
242
243 if (!CheckStudyHardwareClass(study.filter(), hardware_class)) { 228 if (!CheckStudyHardwareClass(study.filter(), hardware_class)) {
244 DVLOG(1) << "Filtered out study " << study.name() << 229 DVLOG(1) << "Filtered out study " << study.name() <<
245 " due to hardware_class."; 230 " due to hardware_class.";
246 return false; 231 return false;
247 } 232 }
248 233
249 if (!CheckStudyCountry(study.filter(), country)) { 234 if (!CheckStudyCountry(study.filter(), country)) {
250 DVLOG(1) << "Filtered out study " << study.name() << " due to country."; 235 DVLOG(1) << "Filtered out study " << study.name() << " due to country.";
251 return false; 236 return false;
252 } 237 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 299
315 for (size_t i = 0; i < expired_studies.size(); ++i) { 300 for (size_t i = 0; i < expired_studies.size(); ++i) {
316 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) { 301 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) {
317 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true, 302 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true,
318 filtered_studies); 303 filtered_studies);
319 } 304 }
320 } 305 }
321 } 306 }
322 307
323 } // namespace variations 308 } // 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