| 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 "chrome/browser/prefs/profile_pref_store_manager.h" | 5 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void DestroyPrefStore() { | 286 void DestroyPrefStore() { |
| 287 if (pref_store_.get()) { | 287 if (pref_store_.get()) { |
| 288 ClearResetRecorded(); | 288 ClearResetRecorded(); |
| 289 // Force everything to be written to disk, triggering the PrefHashFilter | 289 // Force everything to be written to disk, triggering the PrefHashFilter |
| 290 // while our RegistryVerifier is watching. | 290 // while our RegistryVerifier is watching. |
| 291 pref_store_->CommitPendingWrite(); | 291 pref_store_->CommitPendingWrite(); |
| 292 base::RunLoop().RunUntilIdle(); | 292 base::RunLoop().RunUntilIdle(); |
| 293 base::RunLoop run_loop; | 293 base::RunLoop run_loop; |
| 294 JsonPrefStore::GetTaskRunnerForFile(profile_dir_.GetPath(), | 294 JsonPrefStore::GetTaskRunnerForFile(profile_dir_.GetPath(), |
| 295 worker_pool_->pool().get()) | 295 worker_pool_->pool().get()) |
| 296 ->PostTaskAndReply(FROM_HERE, base::Bind(&base::DoNothing), | 296 ->PostTaskAndReply(FROM_HERE, base::BindOnce(&base::DoNothing), |
| 297 run_loop.QuitClosure()); | 297 run_loop.QuitClosure()); |
| 298 run_loop.Run(); | 298 run_loop.Run(); |
| 299 | 299 |
| 300 pref_store_->RemoveObserver(®istry_verifier_); | 300 pref_store_->RemoveObserver(®istry_verifier_); |
| 301 pref_store_ = NULL; | 301 pref_store_ = NULL; |
| 302 // Nothing should have to happen on the background threads, but just in | 302 // Nothing should have to happen on the background threads, but just in |
| 303 // case... | 303 // case... |
| 304 base::RunLoop().RunUntilIdle(); | 304 base::RunLoop().RunUntilIdle(); |
| 305 } | 305 } |
| 306 pref_service_context_.reset(); | 306 pref_service_context_.reset(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 321 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 321 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 322 pref_store->SetValue(kUnprotectedPref, | 322 pref_store->SetValue(kUnprotectedPref, |
| 323 base::MakeUnique<base::Value>(kFoobar), | 323 base::MakeUnique<base::Value>(kFoobar), |
| 324 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 324 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 325 pref_store->RemoveObserver(®istry_verifier_); | 325 pref_store->RemoveObserver(®istry_verifier_); |
| 326 pref_store->CommitPendingWrite(); | 326 pref_store->CommitPendingWrite(); |
| 327 base::RunLoop().RunUntilIdle(); | 327 base::RunLoop().RunUntilIdle(); |
| 328 base::RunLoop run_loop; | 328 base::RunLoop run_loop; |
| 329 JsonPrefStore::GetTaskRunnerForFile(profile_dir_.GetPath(), | 329 JsonPrefStore::GetTaskRunnerForFile(profile_dir_.GetPath(), |
| 330 worker_pool_->pool().get()) | 330 worker_pool_->pool().get()) |
| 331 ->PostTaskAndReply(FROM_HERE, base::Bind(&base::DoNothing), | 331 ->PostTaskAndReply(FROM_HERE, base::BindOnce(&base::DoNothing), |
| 332 run_loop.QuitClosure()); | 332 run_loop.QuitClosure()); |
| 333 run_loop.Run(); | 333 run_loop.Run(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void LoadExistingPrefs() { | 336 void LoadExistingPrefs() { |
| 337 DestroyPrefStore(); | 337 DestroyPrefStore(); |
| 338 pref_store_ = manager_->CreateProfilePrefStore( | 338 pref_store_ = manager_->CreateProfilePrefStore( |
| 339 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, | 339 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, |
| 340 worker_pool_->pool().get(), | 340 worker_pool_->pool().get(), |
| 341 reset_on_load_observer_bindings_.CreateInterfacePtrAndBind(this), | 341 reset_on_load_observer_bindings_.CreateInterfacePtrAndBind(this), |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 LoadExistingPrefs(); | 628 LoadExistingPrefs(); |
| 629 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 629 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 630 VerifyResetRecorded(false); | 630 VerifyResetRecorded(false); |
| 631 } | 631 } |
| 632 | 632 |
| 633 // The parameter controls whether the user pref store is created within a | 633 // The parameter controls whether the user pref store is created within a |
| 634 // service. | 634 // service. |
| 635 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, | 635 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, |
| 636 ProfilePrefStoreManagerTest, | 636 ProfilePrefStoreManagerTest, |
| 637 testing::Bool()); | 637 testing::Bool()); |
| OLD | NEW |