| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/metrics/variations_service.h" | 5 #include "chrome/browser/metrics/variations_service.h" | 
| 6 | 6 | 
| 7 #include <set> | 7 #include <set> | 
| 8 | 8 | 
| 9 #include "base/base64.h" | 9 #include "base/base64.h" | 
| 10 #include "base/build_time.h" | 10 #include "base/build_time.h" | 
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 275 bool VariationsService::CheckStudyVersion( | 275 bool VariationsService::CheckStudyVersion( | 
| 276     const chrome_variations::Study_Filter& filter, | 276     const chrome_variations::Study_Filter& filter, | 
| 277     const std::string& version_string) { | 277     const std::string& version_string) { | 
| 278   const Version version(version_string); | 278   const Version version(version_string); | 
| 279   if (!version.IsValid()) { | 279   if (!version.IsValid()) { | 
| 280     NOTREACHED(); | 280     NOTREACHED(); | 
| 281     return false; | 281     return false; | 
| 282   } | 282   } | 
| 283 | 283 | 
| 284   if (filter.has_min_version()) { | 284   if (filter.has_min_version()) { | 
| 285     const Version min_version(filter.min_version()); | 285     if (version.CompareToWildcardString(filter.min_version()) < 0) | 
| 286     if (!min_version.IsValid()) |  | 
| 287       return false; |  | 
| 288     if (version.CompareTo(min_version) < 0) |  | 
| 289       return false; | 286       return false; | 
| 290   } | 287   } | 
| 291 | 288 | 
| 292   if (filter.has_max_version()) { | 289   if (filter.has_max_version()) { | 
| 293     const Version max_version(filter.max_version()); | 290     if (version.CompareToWildcardString(filter.max_version()) > 0) | 
| 294     if (!max_version.IsValid()) |  | 
| 295       return false; |  | 
| 296     if (version.CompareTo(max_version) > 0) |  | 
| 297       return false; | 291       return false; | 
| 298   } | 292   } | 
| 299 | 293 | 
| 300   return true; | 294   return true; | 
| 301 } | 295 } | 
| 302 | 296 | 
| 303 // static | 297 // static | 
| 304 bool VariationsService::CheckStudyStartDate( | 298 bool VariationsService::CheckStudyStartDate( | 
| 305     const chrome_variations::Study_Filter& filter, | 299     const chrome_variations::Study_Filter& filter, | 
| 306     const base::Time& date_time) { | 300     const base::Time& date_time) { | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 326 | 320 | 
| 327 // static | 321 // static | 
| 328 bool VariationsService::ValidateStudyAndComputeTotalProbability( | 322 bool VariationsService::ValidateStudyAndComputeTotalProbability( | 
| 329     const chrome_variations::Study& study, | 323     const chrome_variations::Study& study, | 
| 330     base::FieldTrial::Probability* total_probability) { | 324     base::FieldTrial::Probability* total_probability) { | 
| 331   // At the moment, a missing default_experiment_name makes the study invalid. | 325   // At the moment, a missing default_experiment_name makes the study invalid. | 
| 332   if (study.default_experiment_name().empty()) { | 326   if (study.default_experiment_name().empty()) { | 
| 333     DVLOG(1) << study.name() << " has no default experiment defined."; | 327     DVLOG(1) << study.name() << " has no default experiment defined."; | 
| 334     return false; | 328     return false; | 
| 335   } | 329   } | 
|  | 330   if (study.filter().has_min_version() && | 
|  | 331       !Version::IsValidWildcardString(study.filter().min_version())) { | 
|  | 332     DVLOG(1) << study.name() << " has invalid min version: " | 
|  | 333              << study.filter().min_version(); | 
|  | 334     return false; | 
|  | 335   } | 
|  | 336   if (study.filter().has_max_version() && | 
|  | 337       !Version::IsValidWildcardString(study.filter().max_version())) { | 
|  | 338     DVLOG(1) << study.name() << " has invalid max version: " | 
|  | 339              << study.filter().max_version(); | 
|  | 340     return false; | 
|  | 341   } | 
| 336 | 342 | 
| 337   const std::string& default_group_name = study.default_experiment_name(); | 343   const std::string& default_group_name = study.default_experiment_name(); | 
| 338   base::FieldTrial::Probability divisor = 0; | 344   base::FieldTrial::Probability divisor = 0; | 
| 339 | 345 | 
| 340   bool found_default_group = false; | 346   bool found_default_group = false; | 
| 341   std::set<std::string> experiment_names; | 347   std::set<std::string> experiment_names; | 
| 342   for (int i = 0; i < study.experiment_size(); ++i) { | 348   for (int i = 0; i < study.experiment_size(); ++i) { | 
| 343     if (study.experiment(i).name().empty()) { | 349     if (study.experiment(i).name().empty()) { | 
| 344       DVLOG(1) << study.name() << " is missing experiment " << i << " name"; | 350       DVLOG(1) << study.name() << " is missing experiment " << i << " name"; | 
| 345       return false; | 351       return false; | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 415       experiments_helper::AssociateGoogleVariationIDForce(study.name(), | 421       experiments_helper::AssociateGoogleVariationIDForce(study.name(), | 
| 416                                                           experiment.name(), | 422                                                           experiment.name(), | 
| 417                                                           variation_id); | 423                                                           variation_id); | 
| 418     } | 424     } | 
| 419   } | 425   } | 
| 420 | 426 | 
| 421   trial->SetForced(); | 427   trial->SetForced(); | 
| 422   if (IsStudyExpired(study, reference_date)) | 428   if (IsStudyExpired(study, reference_date)) | 
| 423     trial->Disable(); | 429     trial->Disable(); | 
| 424 } | 430 } | 
| OLD | NEW | 
|---|