Skip to content

Commit

Permalink
TestingPrefServiceSyncable constructor improved
Browse files Browse the repository at this point in the history
The constructor for `TestingPrefServiceSyncable` is now taking smart
pointers, rather than just taking ownership through pointers. This
change corrects the construction in the codebase of
`TestingPrefServiceSyncable`.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/a154c5ff0d5e12360f6080ef552b09c1979ca27b

commit a154c5ff0d5e12360f6080ef552b09c1979ca27b
Author: Victor Hugo Vianna Silva <victorvianna@google.com>
Date:   Wed Nov 29 09:40:50 2023 +0000

    Improve TestingPrefServiceBase arguments ownership

    Test-only change. Instead of having the constructor take ownership
    of raw pointers, take scoped_refptr<> / unique_ptr<> as arguments
    in the first place.

    Bug: None
  • Loading branch information
cdesouza-chromium committed Dec 13, 2023
1 parent c02d6f9 commit 2f2b36a
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ TEST(AccountConsistencyDisabledTest, NewProfile) {
TestingProfile::Builder profile_builder;
profile_builder.SetIsNewProfile(true);
{
TestingPrefStore* user_prefs = new TestingPrefStore();
auto user_prefs = base::MakeRefCounted<TestingPrefStore>();

// Set the read error so that Profile::IsNewProfile() returns true.
user_prefs->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE);

std::unique_ptr<sync_preferences::TestingPrefServiceSyncable> pref_service =
std::make_unique<sync_preferences::TestingPrefServiceSyncable>(
/*managed_prefs=*/new TestingPrefStore(),
/*supervised_user_prefs=*/new TestingPrefStore(),
/*extension_prefs=*/new TestingPrefStore(),
/*standalone_browser_prefs=*/new TestingPrefStore(), user_prefs,
/*recommended_prefs=*/new TestingPrefStore(),
new user_prefs::PrefRegistrySyncable(), new PrefNotifierImpl());
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
/*supervised_user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
/*standalone_browser_prefs=*/
base::MakeRefCounted<TestingPrefStore>(), std::move(user_prefs),
/*recommended_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>(),
std::make_unique<PrefNotifierImpl>());
RegisterUserProfilePrefs(pref_service->registry());
profile_builder.SetPrefService(std::move(pref_service));
}
Expand Down

0 comments on commit 2f2b36a

Please sign in to comment.