OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/user_prefs/tracked/tracked_preferences_migration.h" | 5 #include "components/user_prefs/tracked/tracked_preferences_migration.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, false)); | 155 pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, false)); |
156 break; | 156 break; |
157 case MOCK_PROTECTED_PREF_STORE: | 157 case MOCK_PROTECTED_PREF_STORE: |
158 store = protected_prefs_.get(); | 158 store = protected_prefs_.get(); |
159 pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, true)); | 159 pref_hash_store.reset(new PrefHashStoreImpl(kSeed, kDeviceId, true)); |
160 break; | 160 break; |
161 } | 161 } |
162 DCHECK(store); | 162 DCHECK(store); |
163 | 163 |
164 base::StringValue string_value(value); | 164 base::StringValue string_value(value); |
165 pref_hash_store | 165 DictionaryHashStoreContents contents(store); |
166 ->BeginTransaction(std::unique_ptr<HashStoreContents>( | 166 pref_hash_store->BeginTransaction(&contents)->StoreHash(key, &string_value); |
167 new DictionaryHashStoreContents(store))) | |
168 ->StoreHash(key, &string_value); | |
169 } | 167 } |
170 | 168 |
171 // Returns true if the store opposite to |store_id| is observed for its next | 169 // Returns true if the store opposite to |store_id| is observed for its next |
172 // successful write. | 170 // successful write. |
173 bool WasOnSuccessfulWriteCallbackRegistered(MockPrefStoreID store_id) { | 171 bool WasOnSuccessfulWriteCallbackRegistered(MockPrefStoreID store_id) { |
174 switch (store_id) { | 172 switch (store_id) { |
175 case MOCK_UNPROTECTED_PREF_STORE: | 173 case MOCK_UNPROTECTED_PREF_STORE: |
176 return !protected_store_successful_write_callback_.is_null(); | 174 return !protected_store_successful_write_callback_.is_null(); |
177 case MOCK_PROTECTED_PREF_STORE: | 175 case MOCK_PROTECTED_PREF_STORE: |
178 return !unprotected_store_successful_write_callback_.is_null(); | 176 return !unprotected_store_successful_write_callback_.is_null(); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 expected_unprotected_values); | 644 expected_unprotected_values); |
647 | 645 |
648 base::StringPairs expected_protected_values; | 646 base::StringPairs expected_protected_values; |
649 expected_protected_values.push_back(std::make_pair( | 647 expected_protected_values.push_back(std::make_pair( |
650 kProtectedPref, kProtectedPrefValue)); | 648 kProtectedPref, kProtectedPrefValue)); |
651 expected_protected_values.push_back(std::make_pair( | 649 expected_protected_values.push_back(std::make_pair( |
652 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); | 650 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); |
653 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); | 651 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); |
654 } | 652 } |
655 } | 653 } |
OLD | NEW |