diff options
author | asvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-06 18:04:29 +0000 |
---|---|---|
committer | asvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-06 18:04:29 +0000 |
commit | 0481124f832fc841b19b0b82bc42e7617f3da8b6 (patch) | |
tree | 0f7771b297dfc1d8e0ac1bfde58f0354b563572c /chrome/common/metrics | |
parent | a7b8020aa91b73aca2e1d06b65569e4892712ebd (diff) | |
download | chromium_src-0481124f832fc841b19b0b82bc42e7617f3da8b6.zip chromium_src-0481124f832fc841b19b0b82bc42e7617f3da8b6.tar.gz chromium_src-0481124f832fc841b19b0b82bc42e7617f3da8b6.tar.bz2 |
Put VariationsService into the chrome_variations namespace.
Also, rename chrome_variations::ID to chrome_variations::VariationID,
since there are other things in that namespace now (which was already
the case with the protobuf classes).
BUG=none
TEST=compiles
Review URL: https://chromiumcodereview.appspot.com/10693106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145608 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/metrics')
-rw-r--r-- | chrome/common/metrics/experiments_helper.cc | 15 | ||||
-rw-r--r-- | chrome/common/metrics/experiments_helper.h | 47 | ||||
-rw-r--r-- | chrome/common/metrics/experiments_helper_unittest.cc | 9 | ||||
-rw-r--r-- | chrome/common/metrics/variation_ids.h | 2 |
4 files changed, 37 insertions, 36 deletions
diff --git a/chrome/common/metrics/experiments_helper.cc b/chrome/common/metrics/experiments_helper.cc index 0fb6fa6..27f0235 100644 --- a/chrome/common/metrics/experiments_helper.cc +++ b/chrome/common/metrics/experiments_helper.cc @@ -32,7 +32,7 @@ class GroupMapAccessor { // Note that this normally only sets the ID for a group the first time, unless // |force| is set to true, in which case it will always override it. void AssociateID(const experiments_helper::SelectedGroupId& group_identifier, - chrome_variations::ID id, + chrome_variations::VariationID id, const bool force) { base::AutoLock scoped_lock(lock_); if (force || @@ -40,7 +40,7 @@ class GroupMapAccessor { group_to_id_map_[group_identifier] = id; } - chrome_variations::ID GetID( + chrome_variations::VariationID GetID( const experiments_helper::SelectedGroupId& group_identifier) { base::AutoLock scoped_lock(lock_); GroupToIDMap::const_iterator it = group_to_id_map_.find(group_identifier); @@ -51,7 +51,7 @@ class GroupMapAccessor { private: typedef std::map<experiments_helper::SelectedGroupId, - chrome_variations::ID, + chrome_variations::VariationID, experiments_helper::SelectedGroupIdCompare> GroupToIDMap; base::Lock lock_; @@ -113,20 +113,21 @@ void GetFieldTrialSelectedGroupIds( void AssociateGoogleVariationID(const std::string& trial_name, const std::string& group_name, - chrome_variations::ID id) { + chrome_variations::VariationID id) { GroupMapAccessor::GetInstance()->AssociateID( MakeSelectedGroupId(trial_name, group_name), id, false); } void AssociateGoogleVariationIDForce(const std::string& trial_name, const std::string& group_name, - chrome_variations::ID id) { + chrome_variations::VariationID id) { GroupMapAccessor::GetInstance()->AssociateID( MakeSelectedGroupId(trial_name, group_name), id, true); } -chrome_variations::ID GetGoogleVariationID(const std::string& trial_name, - const std::string& group_name) { +chrome_variations::VariationID GetGoogleVariationID( + const std::string& trial_name, + const std::string& group_name) { return GroupMapAccessor::GetInstance()->GetID( MakeSelectedGroupId(trial_name, group_name)); } diff --git a/chrome/common/metrics/experiments_helper.h b/chrome/common/metrics/experiments_helper.h index e821d4b..3ee6f37 100644 --- a/chrome/common/metrics/experiments_helper.h +++ b/chrome/common/metrics/experiments_helper.h @@ -31,23 +31,21 @@ // "trial", 1000, "default", 2012, 12, 31, NULL); // const int kHighMemGroup = trial->AppendGroup("HighMem", 20); // const int kLowMemGroup = trial->AppendGroup("LowMem", 20); -// // All groups are now created. We want to associate chrome_variation::IDs -// // with them, so do that now. +// // All groups are now created. We want to associate +// // chrome_variation::VariationIDs with them, so do that now. // AssociateGoogleVariationID("trial", "default", chrome_variations::kValueA); // AssociateGoogleVariationID("trial", "HighMem", chrome_variations::kValueB); // AssociateGoogleVariationID("trial", "LowMem", chrome_variations::kValueC); // -// // Elsewhere, we are interested in retrieving the chrome_variations::ID -// // assocaited with |trial|. -// chrome_variations::ID id = GetGoogleVariationID(trial->name(), -// trial->group_name()); +// // Elsewhere, we are interested in retrieving the VariationID associated +// // with |trial|. +// chrome_variations::VariationID id = +// GetGoogleVariationID(trial->name(), trial->group_name()); // // Do stuff with |id|... // -// The AssociateGoogleVariationID and GetGoogleExperimentID API methods are +// The AssociateGoogleVariationID and GetGoogleVariationID API methods are // thread safe. -// -// TODO(stevet): Rename these methods to AssociateVariationID and GetVariationID -// here and everywhere else. + namespace experiments_helper { // The Unique ID of a trial and its selected group, where the name and group @@ -78,29 +76,30 @@ struct SelectedGroupIdCompare { void GetFieldTrialSelectedGroupIds( std::vector<SelectedGroupId>* name_group_ids); -// Associate a chrome_variations::ID value with a FieldTrial group. If an id was -// previously set for |trial_name| and |group_name|, this does nothing. The -// group is denoted by |trial_name| and |group_name|. This must be called -// whenever you prepare a FieldTrial (create the trial and append groups) that -// needs to have a chrome_variations::ID associated with it so Google servers -// can recognize the FieldTrial. +// Associate a chrome_variations::VariationID value with a FieldTrial group. If +// an id was previously set for |trial_name| and |group_name|, this does +// nothing. The group is denoted by |trial_name| and |group_name|. This must be +// called whenever you prepare a FieldTrial (create the trial and append groups) +// that needs to have a chrome_variations::VariationID associated with it so +// Google servers can recognize the FieldTrial. void AssociateGoogleVariationID(const std::string& trial_name, const std::string& group_name, - chrome_variations::ID id); + chrome_variations::VariationID id); // As above, but overwrites any previously set id. void AssociateGoogleVariationIDForce(const std::string& trial_name, const std::string& group_name, - chrome_variations::ID id); + chrome_variations::VariationID id); -// Retrieve the chrome_variations::ID associated with a FieldTrial group. The -// group is denoted by |trial_name| and |group_name|. This will return -// chrome_variations::kEmptyID if there is currently no associated ID for the -// named group. This API can be nicely combined with +// Retrieve the chrome_variations::VariationID associated with a FieldTrial +// group. The group is denoted by |trial_name| and |group_name|. This will +// return chrome_variations::kEmptyID if there is currently no associated ID +// for the named group. This API can be nicely combined with // FieldTrial::GetFieldTrialSelectedGroupIds to enumerate the // variation IDs for all active FieldTrial groups. -chrome_variations::ID GetGoogleVariationID(const std::string& trial_name, - const std::string& group_name); +chrome_variations::VariationID GetGoogleVariationID( + const std::string& trial_name, + const std::string& group_name); // Generates experiment chunks from |experiment_strings| that are suitable for // crash reporting. diff --git a/chrome/common/metrics/experiments_helper_unittest.cc b/chrome/common/metrics/experiments_helper_unittest.cc index 268d25a..7fe2625 100644 --- a/chrome/common/metrics/experiments_helper_unittest.cc +++ b/chrome/common/metrics/experiments_helper_unittest.cc @@ -19,9 +19,10 @@ namespace experiments_helper { namespace { -// Convenience helper to retrieve the chrome_variations::ID for a FieldTrial. -// Note that this will do the group assignment in |trial| if not already done. -chrome_variations::ID GetIDForTrial(base::FieldTrial* trial) { +// Convenience helper to retrieve the chrome_variations::VariationID for a +// FieldTrial. Note that this will do the group assignment in |trial| if not +// already done. +chrome_variations::VariationID GetIDForTrial(base::FieldTrial* trial) { return GetGoogleVariationID(trial->name(), trial->group_name()); } @@ -195,7 +196,7 @@ TEST_F(ExperimentsHelperTest, NoAssociation) { int winner_group = no_id_trial->AppendGroup(winner, 10); // Ensure that despite the fact that a normal winner is elected, it does not - // have a valid chrome_variations::ID associated with it. + // have a valid chrome_variations::VariationID associated with it. EXPECT_EQ(winner_group, no_id_trial->group()); EXPECT_EQ(winner, no_id_trial->group_name()); EXPECT_EQ(chrome_variations::kEmptyID, GetIDForTrial(no_id_trial.get())); diff --git a/chrome/common/metrics/variation_ids.h b/chrome/common/metrics/variation_ids.h index 8dc025e..6e23dce 100644 --- a/chrome/common/metrics/variation_ids.h +++ b/chrome/common/metrics/variation_ids.h @@ -39,7 +39,7 @@ namespace chrome_variations { // // Anything within the range of a uint32 should be castable to an ID, but // please ensure that they are within the range of the min and max values. -enum ID { +enum VariationID { // Used to represent no associated Chrome variation ID. kEmptyID = 0, |