| 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 21 matching lines...) Expand all Loading... |
| 32 return base::Singleton<GroupMapAccessor>::get(); | 32 return base::Singleton<GroupMapAccessor>::get(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Note that this normally only sets the ID for a group the first time, unless | 35 // Note that this normally only sets the ID for a group the first time, unless |
| 36 // |force| is set to true, in which case it will always override it. | 36 // |force| is set to true, in which case it will always override it. |
| 37 void AssociateID(IDCollectionKey key, | 37 void AssociateID(IDCollectionKey key, |
| 38 const ActiveGroupId& group_identifier, | 38 const ActiveGroupId& group_identifier, |
| 39 const VariationID id, | 39 const VariationID id, |
| 40 const bool force) { | 40 const bool force) { |
| 41 #if !defined(NDEBUG) | 41 #if !defined(NDEBUG) |
| 42 DCHECK_EQ(3, ID_COLLECTION_COUNT); | 42 DCHECK_EQ(4, ID_COLLECTION_COUNT); |
| 43 // Ensure that at most one of the trigger/non-trigger web property IDs are | 43 // Ensure that at most one of the trigger/non-trigger/signed-in web property |
| 44 // set. | 44 // IDs are set. |
| 45 if (key == GOOGLE_WEB_PROPERTIES || key == GOOGLE_WEB_PROPERTIES_TRIGGER) { | 45 if (key == GOOGLE_WEB_PROPERTIES || key == GOOGLE_WEB_PROPERTIES_TRIGGER || |
| 46 IDCollectionKey other_key = key == GOOGLE_WEB_PROPERTIES ? | 46 key == GOOGLE_WEB_PROPERTIES_SIGNED_IN) { |
| 47 GOOGLE_WEB_PROPERTIES_TRIGGER : GOOGLE_WEB_PROPERTIES; | 47 if (key != GOOGLE_WEB_PROPERTIES) |
| 48 DCHECK_EQ(EMPTY_ID, GetID(other_key, group_identifier)); | 48 DCHECK_EQ(EMPTY_ID, GetID(GOOGLE_WEB_PROPERTIES, group_identifier)); |
| 49 if (key != GOOGLE_WEB_PROPERTIES_TRIGGER) { |
| 50 DCHECK_EQ(EMPTY_ID, |
| 51 GetID(GOOGLE_WEB_PROPERTIES_TRIGGER, group_identifier)); |
| 52 } |
| 53 if (key != GOOGLE_WEB_PROPERTIES_SIGNED_IN) { |
| 54 DCHECK_EQ(EMPTY_ID, |
| 55 GetID(GOOGLE_WEB_PROPERTIES_SIGNED_IN, group_identifier)); |
| 56 } |
| 49 } | 57 } |
| 50 | 58 |
| 51 // Validate that all collections with this |group_identifier| have the same | 59 // Validate that all collections with this |group_identifier| have the same |
| 52 // associated ID. | 60 // associated ID. |
| 53 for (int i = 0; i < ID_COLLECTION_COUNT; ++i) { | 61 for (int i = 0; i < ID_COLLECTION_COUNT; ++i) { |
| 54 IDCollectionKey other_key = static_cast<IDCollectionKey>(i); | 62 IDCollectionKey other_key = static_cast<IDCollectionKey>(i); |
| 55 if (other_key == key) | 63 if (other_key == key) |
| 56 continue; | 64 continue; |
| 57 VariationID other_id = GetID(other_key, group_identifier); | 65 VariationID other_id = GetID(other_key, group_identifier); |
| 58 DCHECK(other_id == EMPTY_ID || other_id == id); | 66 DCHECK(other_id == EMPTY_ID || other_id == id); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); | 227 GroupMapAccessor::GetInstance()->ClearAllMapsForTesting(); |
| 220 } | 228 } |
| 221 | 229 |
| 222 void ClearAllVariationParams() { | 230 void ClearAllVariationParams() { |
| 223 base::FieldTrialParamAssociator::GetInstance()->ClearAllParamsForTesting(); | 231 base::FieldTrialParamAssociator::GetInstance()->ClearAllParamsForTesting(); |
| 224 } | 232 } |
| 225 | 233 |
| 226 } // namespace testing | 234 } // namespace testing |
| 227 | 235 |
| 228 } // namespace variations | 236 } // namespace variations |
| OLD | NEW |