[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 5 | #ifndef COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_ |
| 6 | #define COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_ |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 7 | |
avi | 5dd91f8 | 2015-12-25 22:30:46 | [diff] [blame] | 8 | #include "base/macros.h" |
brettw | f00b9b4 | 2016-02-01 22:11:38 | [diff] [blame] | 9 | #include "components/prefs/testing_pref_service.h" |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 10 | #include "components/sync_preferences/pref_service_syncable.h" |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 11 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 12 | namespace user_prefs { |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 13 | class PrefRegistrySyncable; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 14 | } |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 15 | |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 16 | namespace sync_preferences { |
sdefresne | 50c1e52 | 2015-09-18 09:47:51 | [diff] [blame] | 17 | |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 18 | // Test version of PrefServiceSyncable. |
Tim Schumann | 978e750 | 2018-05-07 13:46:52 | [diff] [blame] | 19 | // This class hierarchy has a flaw: TestingPrefServiceBase is inheriting from |
| 20 | // the first template parameter (PrefServiceSyncable in this case). This means, |
| 21 | // all of the supported parameter types must support the same constructor |
| 22 | // signatures -- which they don't. Hence, it's not possible to properly inject |
| 23 | // a PrefModelAssociatorClient. |
| 24 | // TODO(tschumann) The whole purpose of TestingPrefServiceBase is questionable |
| 25 | // and I'd be in favor of removing it completely: |
Toby Huang | 41b07ab | 2020-03-27 21:40:30 | [diff] [blame^] | 26 | // -- it hides the dependency injection of the different stores |
| 27 | // -- just to later offer ways to manipulate specific stores. |
Tim Schumann | 978e750 | 2018-05-07 13:46:52 | [diff] [blame] | 28 | // -- if tests just dependency injects the individual stores directly, they |
| 29 | // already have full control and won't need that indirection at all. |
| 30 | // See PrefServiceSyncableMergeTest as an example of a cleaner way. |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 31 | class TestingPrefServiceSyncable |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 32 | : public TestingPrefServiceBase<PrefServiceSyncable, |
| 33 | user_prefs::PrefRegistrySyncable> { |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 34 | public: |
| 35 | TestingPrefServiceSyncable(); |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 36 | TestingPrefServiceSyncable(TestingPrefStore* managed_prefs, |
Toby Huang | 41b07ab | 2020-03-27 21:40:30 | [diff] [blame^] | 37 | TestingPrefStore* supervised_user_prefs, |
a-v-y | 658f626b | 2017-01-09 09:18:46 | [diff] [blame] | 38 | TestingPrefStore* extension_prefs, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 39 | TestingPrefStore* user_prefs, |
| 40 | TestingPrefStore* recommended_prefs, |
| 41 | user_prefs::PrefRegistrySyncable* pref_registry, |
| 42 | PrefNotifierImpl* pref_notifier); |
dcheng | e59c1bb9 | 2014-10-21 11:55:49 | [diff] [blame] | 43 | ~TestingPrefServiceSyncable() override; |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 44 | |
| 45 | // This is provided as a convenience; on a production PrefService |
| 46 | // you would do all registrations before constructing it, passing it |
[email protected] | e90a01f | 2013-11-19 04:22:12 | [diff] [blame] | 47 | // a PrefRegistry via its constructor (or via e.g. PrefServiceFactory). |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 48 | user_prefs::PrefRegistrySyncable* registry(); |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 49 | |
| 50 | private: |
| 51 | DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable); |
| 52 | }; |
| 53 | |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 54 | } // namespace sync_preferences |
sdefresne | 50c1e52 | 2015-09-18 09:47:51 | [diff] [blame] | 55 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 56 | template <> |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 57 | TestingPrefServiceBase<sync_preferences::PrefServiceSyncable, |
sdefresne | 50c1e52 | 2015-09-18 09:47:51 | [diff] [blame] | 58 | user_prefs::PrefRegistrySyncable>:: |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 59 | TestingPrefServiceBase(TestingPrefStore* managed_prefs, |
Toby Huang | 41b07ab | 2020-03-27 21:40:30 | [diff] [blame^] | 60 | TestingPrefStore* supervised_user_prefs, |
a-v-y | 658f626b | 2017-01-09 09:18:46 | [diff] [blame] | 61 | TestingPrefStore* extension_prefs, |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 62 | TestingPrefStore* user_prefs, |
| 63 | TestingPrefStore* recommended_prefs, |
| 64 | user_prefs::PrefRegistrySyncable* pref_registry, |
| 65 | PrefNotifierImpl* pref_notifier); |
[email protected] | 7688968a | 2013-02-12 21:45:13 | [diff] [blame] | 66 | |
maxbogue | ea16ff41 | 2016-10-28 16:35:29 | [diff] [blame] | 67 | #endif // COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_ |