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

Side by Side Diff: chrome/common/metrics/experiments_helper.h

Issue 10151017: Remove the hash fields from FieldTrials. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ 5 #ifndef CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_
6 #define CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ 6 #define CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 10
(...skipping 10 matching lines...) Expand all
21 // 21 //
22 // Typical usage looks like this: 22 // Typical usage looks like this:
23 // 23 //
24 // // Set up your trial and groups as usual. 24 // // Set up your trial and groups as usual.
25 // FieldTrial* trial = FieldTrialList::FactoryGetFieldTrial( 25 // FieldTrial* trial = FieldTrialList::FactoryGetFieldTrial(
26 // "trial", 1000, "default", 2012, 12, 31, NULL); 26 // "trial", 1000, "default", 2012, 12, 31, NULL);
27 // const int kHighMemGroup = trial->AppendGroup("HighMem", 20); 27 // const int kHighMemGroup = trial->AppendGroup("HighMem", 20);
28 // const int kLowMemGroup = trial->AppendGroup("LowMem", 20); 28 // const int kLowMemGroup = trial->AppendGroup("LowMem", 20);
29 // // All groups are now created. We want to associate GoogleExperimentIDs with 29 // // All groups are now created. We want to associate GoogleExperimentIDs with
30 // // them, so do that now. 30 // // them, so do that now.
31 // AssociateGoogleExperimentID( 31 // AssociateGoogleExperimentID(MakeNameGroupId("trial", "default"), 123);
32 // FieldTrial::MakeNameGroupId("trial", "default"), 123); 32 // AssociateGoogleExperimentID(MakeNameGroupId("trial", "HighMem"), 456);
33 // AssociateGoogleExperimentID( 33 // AssociateGoogleExperimentID(MakeNameGroupId("trial", "LowMem"), 789);
34 // FieldTrial::MakeNameGroupId("trial", "HighMem"), 456);
35 // AssociateGoogleExperimentID(
36 // FieldTrial::MakeNameGroupId("trial", "LowMem"), 789);
37 // 34 //
38 // // Elsewhere, we are interested in retrieving the GoogleExperimentID 35 // // Elsewhere, we are interested in retrieving the GoogleExperimentID
39 // // assocaited with |trial|. 36 // // assocaited with |trial|.
40 // GoogleExperimentID id = GetGoogleExperimentID( 37 // GoogleExperimentID id = GetGoogleExperimentID(
41 // FieldTrial::MakeNameGroupId(trial->name(), trial->group_name())); 38 // MakeNameGroupId(trial->name(), trial->group_name()));
42 // // Do stuff with |id|... 39 // // Do stuff with |id|...
43 // 40 //
44 // The AssociateGoogleExperimentID and GetGoogleExperimentID API methods are 41 // The AssociateGoogleExperimentID and GetGoogleExperimentID API methods are
45 // thread safe. 42 // thread safe.
46 namespace experiments_helper { 43 namespace experiments_helper {
47 44
48 // An ID used by Google servers to identify a local browser experiment. 45 // An ID used by Google servers to identify a local browser experiment.
49 typedef uint32 GoogleExperimentID; 46 typedef uint32 GoogleExperimentID;
50 47
48 typedef std::vector<base::FieldTrial::SelectedGroup> SelectedGroups;
MAD 2012/04/25 20:03:22 Maybe we could put this typedef within the FieldTr
SteveT 2012/04/26 19:03:31 Makes more sense. Done.
49
50 // The Unique ID of a trial, where the name and group identifiers are
51 // hashes of the trial and group name strings.
52 struct NameGroupId {
53 uint32 name;
54 uint32 group;
55 };
56
51 // Used to represent no associated Google experiment ID. Calls to the 57 // Used to represent no associated Google experiment ID. Calls to the
52 // GetGoogleExperimentID API below will return this empty value for FieldTrial 58 // GetGoogleExperimentID API below will return this empty value for FieldTrial
53 // groups uninterested in associating themselves with Google experiments, or 59 // groups uninterested in associating themselves with Google experiments, or
54 // those that have not yet been seen yet. 60 // those that have not yet been seen yet.
55 extern const GoogleExperimentID kEmptyGoogleExperimentID; 61 extern const GoogleExperimentID kEmptyGoogleExperimentID;
56 62
63 // Returns an array of Unique IDs for each Field Trial that has a chosen
64 // group. Field Trials for which a group has not been chosen yet are NOT
65 // returned in this list. In the real world, clients should use
66 // GetFieldTrialNameGroupIds. We expose
67 // GetFieldTrialNameGroupIdsForSelectedGroups for testing, which creates the
68 // NameGroupIds based on |selected_groups|.
69 void GetFieldTrialNameGroupIds(std::vector<NameGroupId>* name_group_ids);
70 void GetFieldTrialNameGroupIdsForSelectedGroups(
MAD 2012/04/25 20:03:22 You could also put this one in an unnamed namespac
SteveT 2012/04/26 19:03:31 Done.
71 const SelectedGroups& selected_groups,
72 std::vector<NameGroupId>* name_group_ids);
73
74 // Helper function to create a NameGroupId from |trial_name| and |group_name|.
75 NameGroupId MakeNameGroupId(const std::string& trial_name,
MAD 2012/04/25 20:03:22 Will this be needed other than by tests? I'm thin
SteveT 2012/04/26 19:03:31 Technically you need it to get GXIDs for individua
MAD 2012/04/26 19:40:12 I think it's fine to test HashName only via this m
76 const std::string& group_name);
77
78 // A wrapper used to expose HashName for testing only.
79 uint32 TestingHashName(const std::string& name);
MAD 2012/04/25 20:03:22 To make it every clearer, you could put it in the
SteveT 2012/04/26 19:03:31 Done.
80
57 // Set the GoogleExperimentID associated with a FieldTrial group. The group is 81 // Set the GoogleExperimentID associated with a FieldTrial group. The group is
58 // denoted by |group_identifier|, which can be created by passing the 82 // denoted by |group_identifier|, which can be created by passing the
59 // FieldTrial's trial and group names to base::FieldTrial::MakeNameGroupId. 83 // FieldTrial's trial and group names to base::FieldTrial::MakeNameGroupId.
60 // This does not need to be called for FieldTrials uninterested in Google 84 // This does not need to be called for FieldTrials uninterested in Google
61 // experiments. 85 // experiments.
62 void AssociateGoogleExperimentID( 86 void AssociateGoogleExperimentID(const NameGroupId& group_identifier,
63 const base::FieldTrial::NameGroupId& group_identifier, 87 GoogleExperimentID id);
64 GoogleExperimentID id);
65 88
66 // Retrieve the GoogleExperimentID associated with a FieldTrial group. The group 89 // Retrieve the GoogleExperimentID associated with a FieldTrial group. The group
67 // is denoted by |group_identifier| (see comment above). This can be nicely 90 // is denoted by |group_identifier| (see comment above). This can be nicely
68 // combined with FieldTrial::GetFieldTrialNameGroupIds to enumerate the 91 // combined with FieldTrial::GetFieldTrialNameGroupIds to enumerate the
69 // GoogleExperimentIDs for all active FieldTrial groups. 92 // GoogleExperimentIDs for all active FieldTrial groups.
70 GoogleExperimentID GetGoogleExperimentID( 93 GoogleExperimentID GetGoogleExperimentID(const NameGroupId& group_identifier);
71 const base::FieldTrial::NameGroupId& group_identifier);
72 94
73 // Get the current set of chosen FieldTrial groups (aka experiments) and send 95 // Get the current set of chosen FieldTrial groups (aka experiments) and send
74 // them to the child process logging module so it can save it for crash dumps. 96 // them to the child process logging module so it can save it for crash dumps.
75 void SetChildProcessLoggingExperimentList(); 97 void SetChildProcessLoggingExperimentList();
76 98
77 } // namespace experiments_helper 99 } // namespace experiments_helper
78 100
79 #endif // CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_ 101 #endif // CHROME_COMMON_METRICS_EXPERIMENTS_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698