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

Unified Diff: chrome/common/metrics/experiments_helper.h

Issue 10165014: Add and implement API to associate Google experiment IDs with FieldTrials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added time variable Created 8 years, 8 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/chrome_tests.gypi ('k') | chrome/common/metrics/experiments_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/metrics/experiments_helper.h
diff --git a/chrome/common/metrics/experiments_helper.h b/chrome/common/metrics/experiments_helper.h
index 630319e79afe479bc050e3551aaa7ff5eb31643e..102e6351c75795bfff3d624294d5b8a89f06f2d9 100644
--- a/chrome/common/metrics/experiments_helper.h
+++ b/chrome/common/metrics/experiments_helper.h
@@ -6,12 +6,74 @@
#define CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_
#pragma once
-namespace ExperimentsHelper {
+#include "base/metrics/field_trial.h"
+
+// This namespace provides various helpers that extend the functionality around
+// base::FieldTrial.
+//
+// This includes a simple API used to handle getting and setting
+// data related to Google-specific experiments in the browser. This is meant to
+// be an extension to the base::FieldTrial for Google-specific functionality.
+//
+// These calls are meant to be made directly after appending all your groups to
+// a FieldTrial (for associating IDs) and any time after the group selection has
+// been done (for retrieving IDs).
+//
+// Typical usage looks like this:
+//
+// // Set up your trial and groups as usual.
+// FieldTrial* trial = FieldTrialList::FactoryGetFieldTrial(
+// "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 GoogleExperimentIDs with
+// // them, so do that now.
+// AssociateGoogleExperimentID(
+// FieldTrial::MakeNameGroupId("trial", "default"), 123);
+// AssociateGoogleExperimentID(
+// FieldTrial::MakeNameGroupId("trial", "HighMem"), 456);
+// AssociateGoogleExperimentID(
+// FieldTrial::MakeNameGroupId("trial", "LowMem"), 789);
+//
+// // Elsewhere, we are interested in retrieving the GoogleExperimentID
+// // assocaited with |trial|.
+// GoogleExperimentID id = GetGoogleExperimentID(
+// FieldTrial::MakeNameGroupId(trial->name(), trial->group_name()));
+// // Do stuff with |id|...
+//
+// The AssociateGoogleExperimentID and GetGoogleExperimentID API methods are
+// thread safe.
+namespace experiments_helper {
+
+// An ID used by Google servers to identify a local browser experiment.
+typedef uint32 GoogleExperimentID;
+
+// Used to represent no associated Google experiment ID. Calls to the
+// GetGoogleExperimentID API below will return this empty value for FieldTrial
+// groups uninterested in associating themselves with Google experiments, or
+// those that have not yet been seen yet.
+extern const GoogleExperimentID kEmptyGoogleExperimentID;
+
+// Set the GoogleExperimentID associated with a FieldTrial group. The group is
+// denoted by |group_identifier|, which can be created by passing the
+// FieldTrial's trial and group names to base::FieldTrial::MakeNameGroupId.
+// This does not need to be called for FieldTrials uninterested in Google
+// experiments.
+void AssociateGoogleExperimentID(
+ const base::FieldTrial::NameGroupId& group_identifier,
+ GoogleExperimentID id);
+
+// Retrieve the GoogleExperimentID associated with a FieldTrial group. The group
+// is denoted by |group_identifier| (see comment above). This can be nicely
+// combined with FieldTrial::GetFieldTrialNameGroupIds to enumerate the
+// GoogleExperimentIDs for all active FieldTrial groups.
+GoogleExperimentID GetGoogleExperimentID(
+ const base::FieldTrial::NameGroupId& group_identifier);
// Get the current set of chosen FieldTrial groups (aka experiments) and send
// them to the child process logging module so it can save it for crash dumps.
void SetChildProcessLoggingExperimentList();
-} // namespace ExperimentsHelper
+} // namespace experiments_helper
#endif // CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/common/metrics/experiments_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698