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

Side by Side Diff: components/user_prefs/tracked/tracked_preferences_migration_unittest.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/prefs/testing_pref_service.h" 16 #include "base/prefs/testing_pref_service.h"
16 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h" 19 #include "components/user_prefs/tracked/dictionary_hash_store_contents.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 base::DictionaryValue* pref_store_contents) override { 52 base::DictionaryValue* pref_store_contents) override {
52 ADD_FAILURE(); 53 ADD_FAILURE();
53 } 54 }
54 55
55 private: 56 private:
56 // InterceptablePrefFilter implementation. 57 // InterceptablePrefFilter implementation.
57 void FinalizeFilterOnLoad( 58 void FinalizeFilterOnLoad(
58 const PostFilterOnLoadCallback& post_filter_on_load_callback, 59 const PostFilterOnLoadCallback& post_filter_on_load_callback,
59 scoped_ptr<base::DictionaryValue> pref_store_contents, 60 scoped_ptr<base::DictionaryValue> pref_store_contents,
60 bool prefs_altered) override { 61 bool prefs_altered) override {
61 post_filter_on_load_callback.Run(pref_store_contents.Pass(), prefs_altered); 62 post_filter_on_load_callback.Run(std::move(pref_store_contents),
63 prefs_altered);
62 } 64 }
63 }; 65 };
64 66
65 // A test fixture designed to be used like this: 67 // A test fixture designed to be used like this:
66 // 1) Set up initial store prefs with PresetStoreValue(). 68 // 1) Set up initial store prefs with PresetStoreValue().
67 // 2) Hand both sets of prefs to the migrator via HandPrefsToMigrator(). 69 // 2) Hand both sets of prefs to the migrator via HandPrefsToMigrator().
68 // 3) Migration completes synchronously when the second store hands its prefs 70 // 3) Migration completes synchronously when the second store hands its prefs
69 // over. 71 // over.
70 // 4) Verifications can be made via various methods of this fixture. 72 // 4) Verifications can be made via various methods of this fixture.
71 // Call Reset() to perform a second migration. 73 // Call Reset() to perform a second migration.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 static_cast<std::string*>(NULL)); 271 static_cast<std::string*>(NULL));
270 } 272 }
271 273
272 // Both stores need to hand their prefs over in order for migration to kick 274 // Both stores need to hand their prefs over in order for migration to kick
273 // in. 275 // in.
274 void HandPrefsToMigrator(MockPrefStoreID store_id) { 276 void HandPrefsToMigrator(MockPrefStoreID store_id) {
275 switch (store_id) { 277 switch (store_id) {
276 case MOCK_UNPROTECTED_PREF_STORE: 278 case MOCK_UNPROTECTED_PREF_STORE:
277 mock_unprotected_pref_filter_.FilterOnLoad( 279 mock_unprotected_pref_filter_.FilterOnLoad(
278 base::Bind(&TrackedPreferencesMigrationTest::GetPrefsBack, 280 base::Bind(&TrackedPreferencesMigrationTest::GetPrefsBack,
279 base::Unretained(this), 281 base::Unretained(this), MOCK_UNPROTECTED_PREF_STORE),
280 MOCK_UNPROTECTED_PREF_STORE), 282 std::move(unprotected_prefs_));
281 unprotected_prefs_.Pass());
282 break; 283 break;
283 case MOCK_PROTECTED_PREF_STORE: 284 case MOCK_PROTECTED_PREF_STORE:
284 mock_protected_pref_filter_.FilterOnLoad( 285 mock_protected_pref_filter_.FilterOnLoad(
285 base::Bind(&TrackedPreferencesMigrationTest::GetPrefsBack, 286 base::Bind(&TrackedPreferencesMigrationTest::GetPrefsBack,
286 base::Unretained(this), 287 base::Unretained(this), MOCK_PROTECTED_PREF_STORE),
287 MOCK_PROTECTED_PREF_STORE), 288 std::move(protected_prefs_));
288 protected_prefs_.Pass());
289 break; 289 break;
290 } 290 }
291 } 291 }
292 292
293 bool HasPrefs(MockPrefStoreID store_id) { 293 bool HasPrefs(MockPrefStoreID store_id) {
294 switch (store_id) { 294 switch (store_id) {
295 case MOCK_UNPROTECTED_PREF_STORE: 295 case MOCK_UNPROTECTED_PREF_STORE:
296 return unprotected_prefs_; 296 return unprotected_prefs_;
297 case MOCK_PROTECTED_PREF_STORE: 297 case MOCK_PROTECTED_PREF_STORE:
298 return protected_prefs_; 298 return protected_prefs_;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 350
351 // Helper given as an InterceptablePrefFilter::FinalizeFilterOnLoadCallback 351 // Helper given as an InterceptablePrefFilter::FinalizeFilterOnLoadCallback
352 // to the migrator to be invoked when it's done. 352 // to the migrator to be invoked when it's done.
353 void GetPrefsBack(MockPrefStoreID store_id, 353 void GetPrefsBack(MockPrefStoreID store_id,
354 scoped_ptr<base::DictionaryValue> prefs, 354 scoped_ptr<base::DictionaryValue> prefs,
355 bool prefs_altered) { 355 bool prefs_altered) {
356 switch (store_id) { 356 switch (store_id) {
357 case MOCK_UNPROTECTED_PREF_STORE: 357 case MOCK_UNPROTECTED_PREF_STORE:
358 EXPECT_FALSE(unprotected_prefs_); 358 EXPECT_FALSE(unprotected_prefs_);
359 unprotected_prefs_ = prefs.Pass(); 359 unprotected_prefs_ = std::move(prefs);
360 migration_modified_unprotected_store_ = prefs_altered; 360 migration_modified_unprotected_store_ = prefs_altered;
361 unprotected_store_migration_complete_ = true; 361 unprotected_store_migration_complete_ = true;
362 break; 362 break;
363 case MOCK_PROTECTED_PREF_STORE: 363 case MOCK_PROTECTED_PREF_STORE:
364 EXPECT_FALSE(protected_prefs_); 364 EXPECT_FALSE(protected_prefs_);
365 protected_prefs_ = prefs.Pass(); 365 protected_prefs_ = std::move(prefs);
366 migration_modified_protected_store_ = prefs_altered; 366 migration_modified_protected_store_ = prefs_altered;
367 protected_store_migration_complete_ = true; 367 protected_store_migration_complete_ = true;
368 break; 368 break;
369 } 369 }
370 } 370 }
371 371
372 // Helper given as a cleaning callback to the migrator. 372 // Helper given as a cleaning callback to the migrator.
373 void RemovePathFromStore(MockPrefStoreID store_id, const std::string& key) { 373 void RemovePathFromStore(MockPrefStoreID store_id, const std::string& key) {
374 switch (store_id) { 374 switch (store_id) {
375 case MOCK_UNPROTECTED_PREF_STORE: 375 case MOCK_UNPROTECTED_PREF_STORE:
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 expected_unprotected_values); 897 expected_unprotected_values);
898 898
899 base::StringPairs expected_protected_values; 899 base::StringPairs expected_protected_values;
900 expected_protected_values.push_back(std::make_pair( 900 expected_protected_values.push_back(std::make_pair(
901 kProtectedPref, kProtectedPrefValue)); 901 kProtectedPref, kProtectedPrefValue));
902 expected_protected_values.push_back(std::make_pair( 902 expected_protected_values.push_back(std::make_pair(
903 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue)); 903 kPreviouslyUnprotectedPref, kPreviouslyUnprotectedPrefValue));
904 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values); 904 VerifyValuesStored(MOCK_PROTECTED_PREF_STORE, expected_protected_values);
905 } 905 }
906 } 906 }
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/tracked_preferences_migration.cc ('k') | components/variations/service/variations_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698