OLD | NEW |
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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 return base::Singleton<GroupMapAccessor>::get(); | 31 return base::Singleton<GroupMapAccessor>::get(); |
32 } | 32 } |
33 | 33 |
34 // Note that this normally only sets the ID for a group the first time, unless | 34 // Note that this normally only sets the ID for a group the first time, unless |
35 // |force| is set to true, in which case it will always override it. | 35 // |force| is set to true, in which case it will always override it. |
36 void AssociateID(IDCollectionKey key, | 36 void AssociateID(IDCollectionKey key, |
37 const ActiveGroupId& group_identifier, | 37 const ActiveGroupId& group_identifier, |
38 const VariationID id, | 38 const VariationID id, |
39 const bool force) { | 39 const bool force) { |
40 #if !defined(NDEBUG) | 40 #if !defined(NDEBUG) |
41 DCHECK_EQ(3, ID_COLLECTION_COUNT); | 41 DCHECK_EQ(4, ID_COLLECTION_COUNT); |
42 // Ensure that at most one of the trigger/non-trigger web property IDs are | 42 // Ensure that at most one of the trigger/non-trigger/signed-in web property |
43 // set. | 43 // IDs are set. |
44 if (key == GOOGLE_WEB_PROPERTIES || key == GOOGLE_WEB_PROPERTIES_TRIGGER) { | 44 if (key == GOOGLE_WEB_PROPERTIES || key == GOOGLE_WEB_PROPERTIES_TRIGGER || |
45 IDCollectionKey other_key = key == GOOGLE_WEB_PROPERTIES ? | 45 key == GOOGLE_WEB_PROPERTIES_SIGNED_IN) { |
46 GOOGLE_WEB_PROPERTIES_TRIGGER : GOOGLE_WEB_PROPERTIES; | 46 if (key != GOOGLE_WEB_PROPERTIES) |
47 DCHECK_EQ(EMPTY_ID, GetID(other_key, group_identifier)); | 47 DCHECK_EQ(EMPTY_ID, GetID(GOOGLE_WEB_PROPERTIES, group_identifier)); |
| 48 if (key != GOOGLE_WEB_PROPERTIES_TRIGGER) { |
| 49 DCHECK_EQ(EMPTY_ID, |
| 50 GetID(GOOGLE_WEB_PROPERTIES_TRIGGER, group_identifier)); |
| 51 } |
| 52 if (key != GOOGLE_WEB_PROPERTIES_SIGNED_IN) { |
| 53 DCHECK_EQ(EMPTY_ID, |
| 54 GetID(GOOGLE_WEB_PROPERTIES_SIGNED_IN, group_identifier)); |
| 55 } |
48 } | 56 } |
49 | 57 |
50 // Validate that all collections with this |group_identifier| have the same | 58 // Validate that all collections with this |group_identifier| have the same |
51 // associated ID. | 59 // associated ID. |
52 for (int i = 0; i < ID_COLLECTION_COUNT; ++i) { | 60 for (int i = 0; i < ID_COLLECTION_COUNT; ++i) { |
53 IDCollectionKey other_key = static_cast<IDCollectionKey>(i); | 61 IDCollectionKey other_key = static_cast<IDCollectionKey>(i); |
54 if (other_key == key) | 62 if (other_key == key) |
55 continue; | 63 continue; |
56 VariationID other_id = GetID(other_key, group_identifier); | 64 VariationID other_id = GetID(other_key, group_identifier); |
57 DCHECK(other_id == EMPTY_ID || other_id == id); | 65 DCHECK(other_id == EMPTY_ID || other_id == id); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); | 206 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); |
199 } | 207 } |
200 | 208 |
201 void ClearAllVariationParams() { | 209 void ClearAllVariationParams() { |
202 base::FieldTrialParamAssociator::GetInstance()->ClearAllParamsForTesting(); | 210 base::FieldTrialParamAssociator::GetInstance()->ClearAllParamsForTesting(); |
203 } | 211 } |
204 | 212 |
205 } // namespace testing | 213 } // namespace testing |
206 | 214 |
207 } // namespace variations | 215 } // namespace variations |
OLD | NEW |