Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / components / sync_preferences / testing_pref_service_syncable.h
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
5 #ifndef COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_
6 #define COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_
7
8 #include "base/macros.h"
9 #include "components/prefs/testing_pref_service.h"
10 #include "components/sync_preferences/pref_service_syncable.h"
11
12 namespace user_prefs {
13 class PrefRegistrySyncable;
14 }
15
16 namespace sync_preferences {
17
18 // Test version of PrefServiceSyncable.
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:
26 //  -- it hides the dependency injetion of the different stores
27 //  -- just to later offer ways to manipulate speficic stores.
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.
31 class TestingPrefServiceSyncable
32     : public TestingPrefServiceBase<PrefServiceSyncable,
33                                     user_prefs::PrefRegistrySyncable> {
34  public:
35   TestingPrefServiceSyncable();
36   TestingPrefServiceSyncable(TestingPrefStore* managed_prefs,
37                              TestingPrefStore* extension_prefs,
38                              TestingPrefStore* user_prefs,
39                              TestingPrefStore* recommended_prefs,
40                              user_prefs::PrefRegistrySyncable* pref_registry,
41                              PrefNotifierImpl* pref_notifier);
42   ~TestingPrefServiceSyncable() override;
43
44   // This is provided as a convenience; on a production PrefService
45   // you would do all registrations before constructing it, passing it
46   // a PrefRegistry via its constructor (or via e.g. PrefServiceFactory).
47   user_prefs::PrefRegistrySyncable* registry();
48
49  private:
50   DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable);
51 };
52
53 }  // namespace sync_preferences
54
55 template <>
56 TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
57                        user_prefs::PrefRegistrySyncable>::
58     TestingPrefServiceBase(TestingPrefStore* managed_prefs,
59                            TestingPrefStore* extension_prefs,
60                            TestingPrefStore* user_prefs,
61                            TestingPrefStore* recommended_prefs,
62                            user_prefs::PrefRegistrySyncable* pref_registry,
63                            PrefNotifierImpl* pref_notifier);
64
65 #endif  // COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_