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

Unified Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 333313003: Simulate variation seeds using installed version string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/variations/variations_service.h ('k') | chrome/browser/upgrade_detector_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations/variations_service.cc
===================================================================
--- chrome/browser/metrics/variations/variations_service.cc (revision 278434)
+++ chrome/browser/metrics/variations/variations_service.cc (working copy)
@@ -13,6 +13,7 @@
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/sys_info.h"
+#include "base/task_runner_util.h"
#include "base/timer/elapsed_timer.h"
#include "base/version.h"
#include "chrome/browser/browser_process.h"
@@ -37,6 +38,10 @@
#include "ui/base/device_form_factor.h"
#include "url/gurl.h"
+#if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
+#include "chrome/browser/upgrade_detector_impl.h"
+#endif
+
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/settings/cros_settings.h"
#endif
@@ -109,6 +114,21 @@
#endif
}
+// Gets the version number to use for variations seed simulation. Must be called
+// on a thread where IO is allowed.
+base::Version GetVersionForSimulation() {
+#if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
+ const base::Version installed_version =
+ UpgradeDetectorImpl::GetCurrentlyInstalledVersion();
+ if (installed_version.IsValid())
+ return installed_version;
+#endif // !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
+
+ // TODO(asvitkine): Get the version that will be used on restart instead of
+ // the current version on Android, iOS and ChromeOS.
+ return base::Version(chrome::VersionInfo().Version());
+}
+
// Gets the restrict parameter from |policy_pref_service| or from Chrome OS
// settings in the case of that platform.
std::string GetRestrictParameterPref(PrefService* policy_pref_service) {
@@ -209,8 +229,8 @@
seed_store_(local_state),
create_trials_from_seed_called_(false),
initial_request_completed_(false),
- resource_request_allowed_notifier_(
- new ResourceRequestAllowedNotifier) {
+ resource_request_allowed_notifier_(new ResourceRequestAllowedNotifier),
+ weak_ptr_factory_(this) {
resource_request_allowed_notifier_->Init(this);
}
@@ -224,7 +244,8 @@
seed_store_(local_state),
create_trials_from_seed_called_(false),
initial_request_completed_(false),
- resource_request_allowed_notifier_(notifier) {
+ resource_request_allowed_notifier_(notifier),
+ weak_ptr_factory_(this) {
resource_request_allowed_notifier_->Init(this);
}
@@ -404,9 +425,9 @@
void VariationsService::StoreSeed(const std::string& seed_data,
const std::string& seed_signature,
const base::Time& date_fetched) {
- VariationsSeed seed;
+ scoped_ptr<VariationsSeed> seed(new VariationsSeed);
if (!seed_store_.StoreSeedData(seed_data, seed_signature, date_fetched,
- &seed)) {
+ seed.get())) {
return;
}
RecordLastFetchTime();
@@ -416,35 +437,12 @@
if (!state_manager_)
return;
- 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;
-
- scoped_ptr<const base::FieldTrial::EntropyProvider> entropy_provider =
- state_manager_->CreateEntropyProvider();
- VariationsSeedSimulator seed_simulator(*entropy_provider);
-
- VariationsSeedSimulator::Result result = seed_simulator.SimulateSeedStudies(
- seed, g_browser_process->GetApplicationLocale(),
- GetReferenceDateForExpiryChecks(local_state_), current_version,
- GetChannelForVariations(), GetCurrentFormFactor(), GetHardwareClass());
-
- 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());
+ base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&GetVersionForSimulation),
+ base::Bind(&VariationsService::PerformSimulationWithVersion,
+ weak_ptr_factory_.GetWeakPtr(), base::Passed(&seed)));
}
void VariationsService::FetchVariationsSeed() {
@@ -546,6 +544,33 @@
request_scheduler_->Reset();
}
+void VariationsService::PerformSimulationWithVersion(
+ scoped_ptr<VariationsSeed> seed,
+ const base::Version& version) {
+ if (version.IsValid())
+ return;
+
+ const base::ElapsedTimer timer;
+
+ scoped_ptr<const base::FieldTrial::EntropyProvider> entropy_provider =
+ state_manager_->CreateEntropyProvider();
+ VariationsSeedSimulator seed_simulator(*entropy_provider);
+
+ VariationsSeedSimulator::Result result = seed_simulator.SimulateSeedStudies(
+ *seed, g_browser_process->GetApplicationLocale(),
+ GetReferenceDateForExpiryChecks(local_state_), version,
+ GetChannelForVariations(), GetCurrentFormFactor(), GetHardwareClass());
+
+ 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::RecordLastFetchTime() {
// local_state_ is NULL in tests, so check it first.
if (local_state_) {
« no previous file with comments | « chrome/browser/metrics/variations/variations_service.h ('k') | chrome/browser/upgrade_detector_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698