From 01748b649babc72e9d421bb7192a45a0707e81ec Mon Sep 17 00:00:00 2001 From: Claudio DeSouza Date: Fri, 1 Dec 2023 10:00:34 +0000 Subject: [PATCH] `TestingPrefServiceSyncable` constructor improved 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 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 --- .../account_consistency_disabled_unittest.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc b/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc index f8d951ab7b3f..c36cabae3085 100644 --- a/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc +++ b/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc @@ -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(); // Set the read error so that Profile::IsNewProfile() returns true. user_prefs->set_read_error(PersistentPrefStore::PREF_READ_ERROR_NO_FILE); std::unique_ptr pref_service = std::make_unique( - /*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(), + /*supervised_user_prefs=*/base::MakeRefCounted(), + /*extension_prefs=*/base::MakeRefCounted(), + /*standalone_browser_prefs=*/ + base::MakeRefCounted(), std::move(user_prefs), + /*recommended_prefs=*/base::MakeRefCounted(), + base::MakeRefCounted(), + std::make_unique()); RegisterUserProfilePrefs(pref_service->registry()); profile_builder.SetPrefService(std::move(pref_service)); }