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" | |
14 | 13 |
15 namespace prefs { | 14 namespace prefs { |
16 namespace { | 15 namespace { |
17 | 16 |
18 std::unique_ptr<PersistentPrefStoreImpl> CreateSimplePersistentPrefStore( | 17 std::unique_ptr<PersistentPrefStoreImpl> CreateSimplePersistentPrefStore( |
19 mojom::SimplePersistentPrefStoreConfigurationPtr config, | 18 mojom::SimplePersistentPrefStoreConfigurationPtr config, |
20 base::SequencedWorkerPool* worker_pool, | 19 base::SequencedWorkerPool* worker_pool, |
21 base::Closure on_initialized) { | 20 base::Closure on_initialized) { |
22 return base::MakeUnique<PersistentPrefStoreImpl>( | 21 return base::MakeUnique<PersistentPrefStoreImpl>( |
23 new JsonPrefStore(config->pref_filename, | 22 new JsonPrefStore(config->pref_filename, |
24 JsonPrefStore::GetTaskRunnerForFile( | 23 JsonPrefStore::GetTaskRunnerForFile( |
25 config->pref_filename.DirName(), worker_pool), | 24 config->pref_filename.DirName(), worker_pool), |
26 nullptr), | 25 nullptr), |
27 std::move(on_initialized)); | 26 nullptr, std::move(on_initialized)); |
28 } | 27 } |
29 | 28 |
30 } // namespace | 29 } // namespace |
31 | 30 |
32 std::unique_ptr<PersistentPrefStoreImpl> CreatePersistentPrefStore( | 31 std::unique_ptr<PersistentPrefStoreImpl> CreatePersistentPrefStore( |
33 mojom::PersistentPrefStoreConfigurationPtr configuration, | 32 mojom::PersistentPrefStoreConfigurationPtr configuration, |
34 base::SequencedWorkerPool* worker_pool, | 33 base::SequencedWorkerPool* worker_pool, |
35 base::Closure on_initialized) { | 34 base::Closure on_initialized) { |
36 if (configuration->is_simple_configuration()) { | 35 if (configuration->is_simple_configuration()) { |
37 return CreateSimplePersistentPrefStore( | 36 return CreateSimplePersistentPrefStore( |
38 std::move(configuration->get_simple_configuration()), worker_pool, | 37 std::move(configuration->get_simple_configuration()), worker_pool, |
39 std::move(on_initialized)); | 38 std::move(on_initialized)); |
40 } | 39 } |
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 } | |
47 NOTREACHED(); | 40 NOTREACHED(); |
48 return nullptr; | 41 return nullptr; |
49 } | 42 } |
50 | 43 |
51 } // namespace prefs | 44 } // namespace prefs |
OLD | NEW |