| OLD | NEW |
| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 if (filter.platform_size() == 0) | 109 if (filter.platform_size() == 0) |
| 110 return true; | 110 return true; |
| 111 | 111 |
| 112 for (int i = 0; i < filter.platform_size(); ++i) { | 112 for (int i = 0; i < filter.platform_size(); ++i) { |
| 113 if (filter.platform(i) == platform) | 113 if (filter.platform(i) == platform) |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool CheckStudyLowEndDevice(const Study::Filter& filter, |
| 120 bool is_low_end_device) { |
| 121 return !filter.has_is_low_end_device() || |
| 122 filter.is_low_end_device() == is_low_end_device; |
| 123 } |
| 124 |
| 119 bool CheckStudyStartDate(const Study::Filter& filter, | 125 bool CheckStudyStartDate(const Study::Filter& filter, |
| 120 const base::Time& date_time) { | 126 const base::Time& date_time) { |
| 121 if (filter.has_start_date()) { | 127 if (filter.has_start_date()) { |
| 122 const base::Time start_date = | 128 const base::Time start_date = |
| 123 ConvertStudyDateToBaseTime(filter.start_date()); | 129 ConvertStudyDateToBaseTime(filter.start_date()); |
| 124 return date_time >= start_date; | 130 return date_time >= start_date; |
| 125 } | 131 } |
| 126 | 132 |
| 127 return true; | 133 return true; |
| 128 } | 134 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 DVLOG(1) << "Filtered out study " << study.name() << " due to end date."; | 244 DVLOG(1) << "Filtered out study " << study.name() << " due to end date."; |
| 239 return false; | 245 return false; |
| 240 } | 246 } |
| 241 | 247 |
| 242 if (!CheckStudyHardwareClass(study.filter(), client_state.hardware_class)) { | 248 if (!CheckStudyHardwareClass(study.filter(), client_state.hardware_class)) { |
| 243 DVLOG(1) << "Filtered out study " << study.name() << | 249 DVLOG(1) << "Filtered out study " << study.name() << |
| 244 " due to hardware_class."; | 250 " due to hardware_class."; |
| 245 return false; | 251 return false; |
| 246 } | 252 } |
| 247 | 253 |
| 254 if (!CheckStudyLowEndDevice(study.filter(), |
| 255 client_state.is_low_end_device)) { |
| 256 DVLOG(1) << "Filtered out study " << study.name() |
| 257 << " due to is_low_end_device."; |
| 258 return false; |
| 259 } |
| 260 |
| 248 const std::string& country = GetClientCountryForStudy(study, client_state); | 261 const std::string& country = GetClientCountryForStudy(study, client_state); |
| 249 if (!CheckStudyCountry(study.filter(), country)) { | 262 if (!CheckStudyCountry(study.filter(), country)) { |
| 250 DVLOG(1) << "Filtered out study " << study.name() << " due to country."; | 263 DVLOG(1) << "Filtered out study " << study.name() << " due to country."; |
| 251 return false; | 264 return false; |
| 252 } | 265 } |
| 253 } | 266 } |
| 254 | 267 |
| 255 DVLOG(1) << "Kept study " << study.name() << "."; | 268 DVLOG(1) << "Kept study " << study.name() << "."; |
| 256 return true; | 269 return true; |
| 257 } | 270 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 285 | 298 |
| 286 for (size_t i = 0; i < expired_studies.size(); ++i) { | 299 for (size_t i = 0; i < expired_studies.size(); ++i) { |
| 287 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) { | 300 if (!base::ContainsKey(created_studies, expired_studies[i]->name())) { |
| 288 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true, | 301 ProcessedStudy::ValidateAndAppendStudy(expired_studies[i], true, |
| 289 filtered_studies); | 302 filtered_studies); |
| 290 } | 303 } |
| 291 } | 304 } |
| 292 } | 305 } |
| 293 | 306 |
| 294 } // namespace variations | 307 } // namespace variations |
| OLD | NEW |