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

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

Issue 2182553002: Add other variations (with ids) for NTPSnippets to chrome://flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alexei's comments #2 Created 4 years, 4 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 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 <memory>
9 #include <string> 10 #include <string>
11 #include <vector>
10 12
11 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
12 #include "components/variations/active_field_trials.h" 14 #include "components/variations/active_field_trials.h"
13 15
14 // This file provides various helpers that extend the functionality around 16 // This file provides various helpers that extend the functionality around
15 // base::FieldTrial. 17 // base::FieldTrial.
16 // 18 //
17 // This includes several simple APIs to handle getting and setting additional 19 // This includes several simple APIs to handle getting and setting additional
18 // data related to Chrome variations, such as parameters and Google variation 20 // data related to Chrome variations, such as parameters and Google variation
19 // IDs. These APIs are meant to extend the base::FieldTrial APIs to offer extra 21 // IDs. These APIs are meant to extend the base::FieldTrial APIs to offer extra
(...skipping 21 matching lines...) Expand all
41 // // use |id| 43 // // use |id|
42 // } 44 // }
43 45
44 namespace base { 46 namespace base {
45 struct Feature; 47 struct Feature;
46 } 48 }
47 49
48 namespace variations { 50 namespace variations {
49 51
50 typedef int VariationID; 52 typedef int VariationID;
53 class VariationsHttpHeaderProvider;
51 54
52 const VariationID EMPTY_ID = 0; 55 const VariationID EMPTY_ID = 0;
53 56
54 // A key into the Associate/Get methods for VariationIDs. This is used to create 57 // A key into the Associate/Get methods for VariationIDs. This is used to create
55 // separate ID associations for separate parties interested in VariationIDs. 58 // separate ID associations for separate parties interested in VariationIDs.
56 enum IDCollectionKey { 59 enum IDCollectionKey {
57 // This collection is used by Google web properties, transmitted through the 60 // This collection is used by Google web properties, transmitted through the
58 // X-Client-Data header. 61 // X-Client-Data header.
59 GOOGLE_WEB_PROPERTIES, 62 GOOGLE_WEB_PROPERTIES,
60 // This collection is used by Google web properties for IDs that trigger 63 // This collection is used by Google web properties for IDs that trigger
61 // server side experimental behavior, transmitted through the 64 // server side experimental behavior, transmitted through the
62 // X-Client-Data header. 65 // X-Client-Data header.
63 GOOGLE_WEB_PROPERTIES_TRIGGER, 66 GOOGLE_WEB_PROPERTIES_TRIGGER,
64 // This collection is used by Google update services, transmitted through the 67 // This collection is used by Google update services, transmitted through the
65 // Google Update experiment labels. 68 // Google Update experiment labels.
66 GOOGLE_UPDATE_SERVICE, 69 GOOGLE_UPDATE_SERVICE,
67 // This collection is used by Chrome Sync services, transmitted through the 70 // This collection is used by Chrome Sync services, transmitted through the
68 // Chrome Sync experiment labels. 71 // Chrome Sync experiment labels.
69 CHROME_SYNC_SERVICE, 72 CHROME_SYNC_SERVICE,
70 // The total count of collections. 73 // The total count of collections.
71 ID_COLLECTION_COUNT, 74 ID_COLLECTION_COUNT,
72 }; 75 };
73 76
77 // Forces the |variation_ids| (possible extended by |command_line_variation_ids|
78 // passed in a command line flag) into a VariationsHttpHeaderProvider that it
79 // returns.
80 VariationsHttpHeaderProvider* ForceVariationIDsForHttpHeaders(
81 std::vector<std::string> variation_ids,
82 std::string command_line_variation_ids);
83
74 // Associate a variations::VariationID value with a FieldTrial group for 84 // Associate a variations::VariationID value with a FieldTrial group for
75 // collection |key|. If an id was previously set for |trial_name| and 85 // collection |key|. If an id was previously set for |trial_name| and
76 // |group_name|, this does nothing. The group is denoted by |trial_name| and 86 // |group_name|, this does nothing. The group is denoted by |trial_name| and
77 // |group_name|. This must be called whenever a FieldTrial is prepared (create 87 // |group_name|. This must be called whenever a FieldTrial is prepared (create
78 // the trial and append groups) and needs to have a variations::VariationID 88 // the trial and append groups) and needs to have a variations::VariationID
79 // associated with it so Google servers can recognize the FieldTrial. 89 // associated with it so Google servers can recognize the FieldTrial.
80 // Thread safe. 90 // Thread safe.
81 void AssociateGoogleVariationID(IDCollectionKey key, 91 void AssociateGoogleVariationID(IDCollectionKey key,
82 const std::string& trial_name, 92 const std::string& trial_name,
83 const std::string& group_name, 93 const std::string& group_name,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void ClearAllVariationIDs(); 203 void ClearAllVariationIDs();
194 204
195 // Clears all of the associated params. 205 // Clears all of the associated params.
196 void ClearAllVariationParams(); 206 void ClearAllVariationParams();
197 207
198 } // namespace testing 208 } // namespace testing
199 209
200 } // namespace variations 210 } // namespace variations
201 211
202 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_ 212 #endif // COMPONENTS_VARIATIONS_VARIATIONS_ASSOCIATED_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698