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/pref_store_manager_impl.h" | 5 #include "services/preferences/pref_store_manager_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const ConnectCallback& callback) { | 241 const ConnectCallback& callback) { |
242 std::vector<std::string> observed_prefs; | 242 std::vector<std::string> observed_prefs; |
243 for (auto& registration : pref_registry->registrations) { | 243 for (auto& registration : pref_registry->registrations) { |
244 observed_prefs.push_back(registration.first); | 244 observed_prefs.push_back(registration.first); |
245 const auto& key = registration.first; | 245 const auto& key = registration.first; |
246 auto& default_value = registration.second->default_value; | 246 auto& default_value = registration.second->default_value; |
247 const base::Value* old_default = nullptr; | 247 const base::Value* old_default = nullptr; |
248 // TODO(sammc): Once non-owning registrations are supported, disallow | 248 // TODO(sammc): Once non-owning registrations are supported, disallow |
249 // multiple owners instead of just checking for consistent defaults. | 249 // multiple owners instead of just checking for consistent defaults. |
250 if (defaults_->GetValue(key, &old_default)) | 250 if (defaults_->GetValue(key, &old_default)) |
251 DCHECK(old_default->Equals(default_value.get())); | 251 DCHECK_EQ(*old_default, default_value); |
252 else | 252 else |
253 defaults_->SetDefaultValue(key, std::move(default_value)); | 253 defaults_->SetDefaultValue(key, default_value.CreateDeepCopy()); |
254 } | 254 } |
255 | 255 |
256 // Only connect to pref stores the client isn't already connected to. | 256 // Only connect to pref stores the client isn't already connected to. |
257 PrefStorePtrs ptrs; | 257 PrefStorePtrs ptrs; |
258 for (const auto& entry : pref_store_ptrs_) { | 258 for (const auto& entry : pref_store_ptrs_) { |
259 if (!base::ContainsValue(already_connected_types, entry.first)) { | 259 if (!base::ContainsValue(already_connected_types, entry.first)) { |
260 ptrs.insert(std::make_pair(entry.first, entry.second.get())); | 260 ptrs.insert(std::make_pair(entry.first, entry.second.get())); |
261 } | 261 } |
262 } | 262 } |
263 ConnectionBarrier::Create( | 263 ConnectionBarrier::Create( |
264 ptrs, | 264 ptrs, |
265 persistent_pref_store_->CreateConnection( | 265 persistent_pref_store_->CreateConnection( |
266 PersistentPrefStoreImpl::ObservedPrefs(observed_prefs.begin(), | 266 PersistentPrefStoreImpl::ObservedPrefs(observed_prefs.begin(), |
267 observed_prefs.end())), | 267 observed_prefs.end())), |
268 observed_prefs, callback); | 268 observed_prefs, callback); |
269 } | 269 } |
270 | 270 |
271 void PrefStoreManagerImpl::OnPersistentPrefStoreReady() { | 271 void PrefStoreManagerImpl::OnPersistentPrefStoreReady() { |
272 DVLOG(1) << "PersistentPrefStore ready"; | 272 DVLOG(1) << "PersistentPrefStore ready"; |
273 if (AllConnected()) { | 273 if (AllConnected()) { |
274 ProcessPendingConnects(); | 274 ProcessPendingConnects(); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 } // namespace prefs | 278 } // namespace prefs |
OLD | NEW |