Index: chrome/browser/metrics/variations/variations_service.cc |
=================================================================== |
--- chrome/browser/metrics/variations/variations_service.cc (revision 265923) |
+++ chrome/browser/metrics/variations/variations_service.cc (working copy) |
@@ -12,6 +12,7 @@ |
#include "base/metrics/sparse_histogram.h" |
#include "base/prefs/pref_registry_simple.h" |
#include "base/prefs/pref_service.h" |
+#include "base/timer/elapsed_timer.h" |
#include "base/version.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/network_time/network_time_tracker.h" |
@@ -20,6 +21,7 @@ |
#include "components/user_prefs/pref_registry_syncable.h" |
#include "components/variations/proto/variations_seed.pb.h" |
#include "components/variations/variations_seed_processor.h" |
+#include "components/variations/variations_seed_simulator.h" |
#include "content/public/browser/browser_thread.h" |
#include "net/base/load_flags.h" |
#include "net/base/net_errors.h" |
@@ -381,9 +383,46 @@ |
void VariationsService::StoreSeed(const std::string& seed_data, |
const std::string& seed_signature, |
const base::Time& date_fetched) { |
- if (!seed_store_.StoreSeedData(seed_data, seed_signature, date_fetched)) |
+ VariationsSeed seed; |
+ if (!seed_store_.StoreSeedData(seed_data, seed_signature, date_fetched, |
+ &seed)) { |
return; |
+ } |
RecordLastFetchTime(); |
+ |
+ const base::ElapsedTimer timer; |
+ |
+ // TODO(asvitkine): Get the version that will be used on restart instead of |
+ // the current version (i.e. if an update has been downloaded). |
+ const chrome::VersionInfo current_version_info; |
+ if (!current_version_info.is_valid()) |
+ return; |
+ |
+ const base::Version current_version(current_version_info.Version()); |
+ if (!current_version.IsValid()) |
+ return; |
+ |
+ const base::FieldTrial::EntropyProvider* entropy_provider = |
+ base::FieldTrialList::GetEntropyProviderForOneTimeRandomization(); |
+ // One-time randomization should be supported by the global FieldTrialList in |
+ // the process the VariationService is running in, so |entropy_provider| must |
+ // be non-NULL. |
+ DCHECK(entropy_provider); |
+ VariationsSeedSimulator seed_simulator(*entropy_provider); |
+ |
+ VariationsSeedSimulator::Result result = seed_simulator.SimulateSeedStudies( |
+ seed, g_browser_process->GetApplicationLocale(), |
+ GetReferenceDateForExpiryChecks(local_state_), current_version, |
+ GetChannelForVariations(), GetCurrentFormFactor()); |
+ |
+ UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.NormalChanges", |
+ result.normal_group_change_count); |
+ UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillBestEffortChanges", |
+ result.kill_best_effort_group_change_count); |
+ UMA_HISTOGRAM_COUNTS_100("Variations.SimulateSeed.KillCriticalChanges", |
+ result.kill_critical_group_change_count); |
+ |
+ UMA_HISTOGRAM_TIMES("Variations.SimulateSeed.Duration", timer.Elapsed()); |
} |
void VariationsService::FetchVariationsSeed() { |