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

Unified Diff: base/metrics/field_trial.cc

Issue 9117037: Added a Unique ID for a Field Trial containing it's hashed name and the selected group ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: base/metrics/field_trial.cc
===================================================================
--- base/metrics/field_trial.cc (revision 118842)
+++ base/metrics/field_trial.cc (working copy)
@@ -5,6 +5,7 @@
#include "base/metrics/field_trial.h"
#include "base/build_time.h"
+#include "base/hash_tables.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/sha1.h"
@@ -138,6 +139,13 @@
return group_name_;
}
+bool FieldTrial::GetUID(UID* uid) {
+ if (group_ == kNotFinalized)
+ return false;
+ *uid = std::make_pair(BASE_HASH_NAMESPACE::hash_value(name_), group_);
jar (doing other things) 2012/01/24 19:19:45 IMO, you should consider generating the hash once
MAD 2012/01/24 20:30:24 Yes, good point, I agree... Done...
+ return true;
+}
+
// static
std::string FieldTrial::MakeName(const std::string& name_prefix,
const std::string& trial_name) {
@@ -272,6 +280,21 @@
}
// static
+void FieldTrialList::GetFieldTrialUIDs(std::vector<FieldTrial::UID>* uids) {
+ if (!global_)
+ return;
+ DCHECK(uids->empty());
+ AutoLock auto_lock(global_->lock_);
jar (doing other things) 2012/01/24 19:19:45 This is probably ok. I'm always careful to do as
MAD 2012/01/24 20:30:24 Done...
+
+ for (RegistrationList::iterator it = global_->registered_.begin();
+ it != global_->registered_.end(); ++it) {
+ FieldTrial::UID uid;
+ if (it->second->GetUID(&uid))
+ uids->push_back(uid);
+ }
+}
+
+// static
bool FieldTrialList::CreateTrialsInChildProcess(
const std::string& parent_trials) {
DCHECK(global_);

Powered by Google App Engine
This is Rietveld 408576698