| 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_factory.h" | 5 #include "services/preferences/persistent_pref_store_factory.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "components/prefs/json_pref_store.h" | 10 #include "components/prefs/json_pref_store.h" |
| 11 #include "components/prefs/pref_filter.h" | 11 #include "components/prefs/pref_filter.h" |
| 12 #include "services/preferences/persistent_pref_store_impl.h" | 12 #include "services/preferences/persistent_pref_store_impl.h" |
| 13 #include "services/preferences/tracked/tracked_persistent_pref_store_factory.h" |
| 13 | 14 |
| 14 namespace prefs { | 15 namespace prefs { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 std::unique_ptr<PersistentPrefStoreImpl> CreateSimplePersistentPrefStore( | 18 std::unique_ptr<PersistentPrefStoreImpl> CreateSimplePersistentPrefStore( |
| 18 mojom::SimplePersistentPrefStoreConfigurationPtr config, | 19 mojom::SimplePersistentPrefStoreConfigurationPtr config, |
| 19 base::SequencedWorkerPool* worker_pool, | 20 base::SequencedWorkerPool* worker_pool, |
| 20 base::Closure on_initialized) { | 21 base::Closure on_initialized) { |
| 21 return base::MakeUnique<PersistentPrefStoreImpl>( | 22 return base::MakeUnique<PersistentPrefStoreImpl>( |
| 22 new JsonPrefStore(config->pref_filename, | 23 new JsonPrefStore(config->pref_filename, |
| 23 JsonPrefStore::GetTaskRunnerForFile( | 24 JsonPrefStore::GetTaskRunnerForFile( |
| 24 config->pref_filename.DirName(), worker_pool), | 25 config->pref_filename.DirName(), worker_pool), |
| 25 nullptr), | 26 nullptr), |
| 26 nullptr, std::move(on_initialized)); | 27 std::move(on_initialized)); |
| 27 } | 28 } |
| 28 | 29 |
| 29 } // namespace | 30 } // namespace |
| 30 | 31 |
| 31 std::unique_ptr<PersistentPrefStoreImpl> CreatePersistentPrefStore( | 32 std::unique_ptr<PersistentPrefStoreImpl> CreatePersistentPrefStore( |
| 32 mojom::PersistentPrefStoreConfigurationPtr configuration, | 33 mojom::PersistentPrefStoreConfigurationPtr configuration, |
| 33 base::SequencedWorkerPool* worker_pool, | 34 base::SequencedWorkerPool* worker_pool, |
| 34 base::Closure on_initialized) { | 35 base::Closure on_initialized) { |
| 35 if (configuration->is_simple_configuration()) { | 36 if (configuration->is_simple_configuration()) { |
| 36 return CreateSimplePersistentPrefStore( | 37 return CreateSimplePersistentPrefStore( |
| 37 std::move(configuration->get_simple_configuration()), worker_pool, | 38 std::move(configuration->get_simple_configuration()), worker_pool, |
| 38 std::move(on_initialized)); | 39 std::move(on_initialized)); |
| 39 } | 40 } |
| 41 if (configuration->is_tracked_configuration()) { |
| 42 return base::MakeUnique<PersistentPrefStoreImpl>( |
| 43 CreateTrackedPersistentPrefStore( |
| 44 std::move(configuration->get_tracked_configuration()), worker_pool), |
| 45 std::move(on_initialized)); |
| 46 } |
| 40 NOTREACHED(); | 47 NOTREACHED(); |
| 41 return nullptr; | 48 return nullptr; |
| 42 } | 49 } |
| 43 | 50 |
| 44 } // namespace prefs | 51 } // namespace prefs |
| OLD | NEW |