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

Side by Side Diff: components/variations/variations_associated_data.h

Issue 286063004: Move active field trial API to variations component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « components/variations.gypi ('k') | components/variations/variations_associated_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ 5 #ifndef COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ 6 #define COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "components/variations/active_field_trials.h"
Ilya Sherman 2014/05/19 12:29:42 nit: Can this be moved into the .cc file?
Alexei Svitkine (slow) 2014/05/19 12:50:47 Done.
12 13
13 // This file provides various helpers that extend the functionality around 14 // This file provides various helpers that extend the functionality around
14 // base::FieldTrial. 15 // base::FieldTrial.
15 // 16 //
16 // This includes several simple APIs to handle getting and setting additional 17 // This includes several simple APIs to handle getting and setting additional
17 // data related to Chrome variations, such as parameters and Google variation 18 // data related to Chrome variations, such as parameters and Google variation
18 // IDs. These APIs are meant to extend the base::FieldTrial APIs to offer extra 19 // IDs. These APIs are meant to extend the base::FieldTrial APIs to offer extra
19 // functionality that is not offered by the simpler base::FieldTrial APIs. 20 // functionality that is not offered by the simpler base::FieldTrial APIs.
20 // 21 //
21 // The AssociateGoogleVariationID and AssociateVariationParams functions are 22 // The AssociateGoogleVariationID and AssociateVariationParams functions are
(...skipping 17 matching lines...) Expand all
39 // if (id != chrome_variations::kEmptyID) { 40 // if (id != chrome_variations::kEmptyID) {
40 // // use |id| 41 // // use |id|
41 // } 42 // }
42 43
43 namespace chrome_variations { 44 namespace chrome_variations {
44 45
45 typedef int VariationID; 46 typedef int VariationID;
46 47
47 const VariationID EMPTY_ID = 0; 48 const VariationID EMPTY_ID = 0;
48 49
49 // The Unique ID of a trial and its active group, where the name and group
50 // identifiers are hashes of the trial and group name strings.
51 struct ActiveGroupId {
52 uint32 name;
53 uint32 group;
54 };
55
56 // Returns an ActiveGroupId struct for the given trial and group names.
57 ActiveGroupId MakeActiveGroupId(const std::string& trial_name,
58 const std::string& group_name);
59
60 // We need to supply a Compare class for templates since ActiveGroupId is a
61 // user-defined type.
62 struct ActiveGroupIdCompare {
63 bool operator() (const ActiveGroupId& lhs, const ActiveGroupId& rhs) const {
64 // The group and name fields are just SHA-1 Hashes, so we just need to treat
65 // them as IDs and do a less-than comparison. We test group first, since
66 // name is more likely to collide.
67 if (lhs.group != rhs.group)
68 return lhs.group < rhs.group;
69 return lhs.name < rhs.name;
70 }
71 };
72
73 // A key into the Associate/Get methods for VariationIDs. This is used to create 50 // A key into the Associate/Get methods for VariationIDs. This is used to create
74 // separate ID associations for separate parties interested in VariationIDs. 51 // separate ID associations for separate parties interested in VariationIDs.
75 enum IDCollectionKey { 52 enum IDCollectionKey {
76 // This collection is used by Google web properties, transmitted through the 53 // This collection is used by Google web properties, transmitted through the
77 // X-Client-Data header. 54 // X-Client-Data header.
78 GOOGLE_WEB_PROPERTIES, 55 GOOGLE_WEB_PROPERTIES,
79 // This collection is used by Google web properties for IDs that trigger 56 // This collection is used by Google web properties for IDs that trigger
80 // server side experimental behavior, transmitted through the 57 // server side experimental behavior, transmitted through the
81 // X-Client-Data header. 58 // X-Client-Data header.
82 GOOGLE_WEB_PROPERTIES_TRIGGER, 59 GOOGLE_WEB_PROPERTIES_TRIGGER,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void ClearAllVariationIDs(); 127 void ClearAllVariationIDs();
151 128
152 // Clears all of the associated params. 129 // Clears all of the associated params.
153 void ClearAllVariationParams(); 130 void ClearAllVariationParams();
154 131
155 } // namespace testing 132 } // namespace testing
156 133
157 } // namespace chrome_variations 134 } // namespace chrome_variations
158 135
159 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ 136 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
OLDNEW
« no previous file with comments | « components/variations.gypi ('k') | components/variations/variations_associated_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698