OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/preferences/persistent_pref_store_impl.h" | 5 #include "services/preferences/persistent_pref_store_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 pref_store_ = nullptr; | 112 pref_store_ = nullptr; |
113 base::RunLoop().RunUntilIdle(); | 113 base::RunLoop().RunUntilIdle(); |
114 impl_.reset(); | 114 impl_.reset(); |
115 base::RunLoop().RunUntilIdle(); | 115 base::RunLoop().RunUntilIdle(); |
116 } | 116 } |
117 | 117 |
118 void CreateImpl(scoped_refptr<PersistentPrefStore> backing_pref_store) { | 118 void CreateImpl(scoped_refptr<PersistentPrefStore> backing_pref_store) { |
119 base::RunLoop run_loop; | 119 base::RunLoop run_loop; |
120 bool initialized = backing_pref_store->IsInitializationComplete(); | 120 bool initialized = backing_pref_store->IsInitializationComplete(); |
121 impl_ = base::MakeUnique<PersistentPrefStoreImpl>( | 121 impl_ = base::MakeUnique<PersistentPrefStoreImpl>( |
122 std::move(backing_pref_store), nullptr, run_loop.QuitClosure()); | 122 std::move(backing_pref_store), run_loop.QuitClosure()); |
123 if (!initialized) | 123 if (!initialized) |
124 run_loop.Run(); | 124 run_loop.Run(); |
125 pref_store_ = CreateConnection(); | 125 pref_store_ = CreateConnection(); |
126 } | 126 } |
127 | 127 |
128 scoped_refptr<PersistentPrefStore> CreateConnection( | 128 scoped_refptr<PersistentPrefStore> CreateConnection( |
129 PersistentPrefStoreImpl::ObservedPrefs observed_prefs = | 129 PersistentPrefStoreImpl::ObservedPrefs observed_prefs = |
130 PersistentPrefStoreImpl::ObservedPrefs()) { | 130 PersistentPrefStoreImpl::ObservedPrefs()) { |
131 if (observed_prefs.empty()) | 131 if (observed_prefs.empty()) |
132 observed_prefs.insert({kKey, kOtherKey}); | 132 observed_prefs.insert({kKey, kOtherKey}); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 base::RunLoop run_loop; | 327 base::RunLoop run_loop; |
328 EXPECT_CALL(*backing_store, ClearMutableValues()) | 328 EXPECT_CALL(*backing_store, ClearMutableValues()) |
329 .WillOnce(WithoutArgs(Invoke([&run_loop]() { run_loop.Quit(); }))); | 329 .WillOnce(WithoutArgs(Invoke([&run_loop]() { run_loop.Quit(); }))); |
330 EXPECT_CALL(*backing_store, CommitPendingWrite()).Times(1); | 330 EXPECT_CALL(*backing_store, CommitPendingWrite()).Times(1); |
331 pref_store()->ClearMutableValues(); | 331 pref_store()->ClearMutableValues(); |
332 run_loop.Run(); | 332 run_loop.Run(); |
333 } | 333 } |
334 | 334 |
335 } // namespace | 335 } // namespace |
336 } // namespace prefs | 336 } // namespace prefs |
OLD | NEW |