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

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

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
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 #include "components/variations/variations_associated_data.h" 5 #include "components/variations/variations_associated_data.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "components/variations/metrics_util.h"
13 12
14 namespace chrome_variations { 13 namespace chrome_variations {
15 14
16 namespace { 15 namespace {
17 16
18 // The internal singleton accessor for the map, used to keep it thread-safe. 17 // The internal singleton accessor for the map, used to keep it thread-safe.
19 class GroupMapAccessor { 18 class GroupMapAccessor {
20 public: 19 public:
21 typedef std::map<ActiveGroupId, VariationID, ActiveGroupIdCompare> 20 typedef std::map<ActiveGroupId, VariationID, ActiveGroupIdCompare>
22 GroupToIDMap; 21 GroupToIDMap;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 165 }
167 166
168 base::Lock lock_; 167 base::Lock lock_;
169 std::map<VariationKey, VariationParams> variation_params_; 168 std::map<VariationKey, VariationParams> variation_params_;
170 169
171 DISALLOW_COPY_AND_ASSIGN(VariationsParamAssociator); 170 DISALLOW_COPY_AND_ASSIGN(VariationsParamAssociator);
172 }; 171 };
173 172
174 } // namespace 173 } // namespace
175 174
176 ActiveGroupId MakeActiveGroupId(const std::string& trial_name,
177 const std::string& group_name) {
178 ActiveGroupId id;
179 id.name = metrics::HashName(trial_name);
180 id.group = metrics::HashName(group_name);
181 return id;
182 }
183
184 void AssociateGoogleVariationID(IDCollectionKey key, 175 void AssociateGoogleVariationID(IDCollectionKey key,
185 const std::string& trial_name, 176 const std::string& trial_name,
186 const std::string& group_name, 177 const std::string& group_name,
187 VariationID id) { 178 VariationID id) {
188 GroupMapAccessor::GetInstance()->AssociateID( 179 GroupMapAccessor::GetInstance()->AssociateID(
189 key, MakeActiveGroupId(trial_name, group_name), id, false); 180 key, MakeActiveGroupId(trial_name, group_name), id, false);
190 } 181 }
191 182
192 void AssociateGoogleVariationIDForce(IDCollectionKey key, 183 void AssociateGoogleVariationIDForce(IDCollectionKey key,
193 const std::string& trial_name, 184 const std::string& trial_name,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); 228 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting();
238 } 229 }
239 230
240 void ClearAllVariationParams() { 231 void ClearAllVariationParams() {
241 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting(); 232 VariationsParamAssociator::GetInstance()->ClearAllParamsForTesting();
242 } 233 }
243 234
244 } // namespace testing 235 } // namespace testing
245 236
246 } // namespace chrome_variations 237 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698