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

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 11783033: Fix problem where field trials using kExpirationYearInFuture could get disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
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/variations_service.h" 5 #include "chrome/browser/metrics/variations/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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 base::FieldTrial::Probability total_probability = 0; 525 base::FieldTrial::Probability total_probability = 0;
526 if (!ValidateStudyAndComputeTotalProbability(study, &total_probability)) 526 if (!ValidateStudyAndComputeTotalProbability(study, &total_probability))
527 return; 527 return;
528 528
529 // The trial is created without specifying an expiration date because the 529 // The trial is created without specifying an expiration date because the
530 // expiration check in field_trial.cc is based on the build date. Instead, 530 // expiration check in field_trial.cc is based on the build date. Instead,
531 // the expiration check using |reference_date| is done explicitly below. 531 // the expiration check using |reference_date| is done explicitly below.
532 scoped_refptr<base::FieldTrial> trial( 532 scoped_refptr<base::FieldTrial> trial(
533 base::FieldTrialList::FactoryGetFieldTrial( 533 base::FieldTrialList::FactoryGetFieldTrial(
534 study.name(), total_probability, study.default_experiment_name(), 534 study.name(), total_probability, study.default_experiment_name(),
535 base::FieldTrialList::kExpirationYearInFuture, 1, 1, NULL)); 535 base::FieldTrialList::kNoExpirationYear, 1, 1, NULL));
536 536
537 if (study.has_consistency() && 537 if (study.has_consistency() &&
538 study.consistency() == Study_Consistency_PERMANENT) { 538 study.consistency() == Study_Consistency_PERMANENT) {
539 trial->UseOneTimeRandomization(); 539 trial->UseOneTimeRandomization();
540 } 540 }
541 541
542 for (int i = 0; i < study.experiment_size(); ++i) { 542 for (int i = 0; i < study.experiment_size(); ++i) {
543 const Study_Experiment& experiment = study.experiment(i); 543 const Study_Experiment& experiment = study.experiment(i);
544 if (experiment.name() != study.default_experiment_name()) 544 if (experiment.name() != study.default_experiment_name())
545 trial->AppendGroup(experiment.name(), experiment.probability_weight()); 545 trial->AppendGroup(experiment.name(), experiment.probability_weight());
546 546
547 if (experiment.has_experiment_id()) { 547 if (experiment.has_experiment_id()) {
548 const VariationID variation_id = 548 const VariationID variation_id =
549 static_cast<VariationID>(experiment.experiment_id()); 549 static_cast<VariationID>(experiment.experiment_id());
550 AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES, 550 AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES,
551 study.name(), 551 study.name(),
552 experiment.name(), 552 experiment.name(),
553 variation_id); 553 variation_id);
554 } 554 }
555 } 555 }
556 556
557 trial->SetForced(); 557 trial->SetForced();
558 if (IsStudyExpired(study, reference_date)) 558 if (IsStudyExpired(study, reference_date))
559 trial->Disable(); 559 trial->Disable();
560 } 560 }
561 561
562 } // namespace chrome_variations 562 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | chrome/common/metrics/entropy_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698