blob: fcbad542fdb06cabe2508903f9506d3e0b53ae19 [file] [log] [blame]
[email protected]7688968a2013-02-12 21:45:131// 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
maxbogueea16ff412016-10-28 16:35:295#ifndef COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_
6#define COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_
[email protected]7688968a2013-02-12 21:45:137
avi5dd91f82015-12-25 22:30:468#include "base/macros.h"
brettwf00b9b42016-02-01 22:11:389#include "components/prefs/testing_pref_service.h"
maxbogueea16ff412016-10-28 16:35:2910#include "components/sync_preferences/pref_service_syncable.h"
[email protected]7688968a2013-02-12 21:45:1311
[email protected]443e9312013-05-06 06:17:3412namespace user_prefs {
[email protected]7688968a2013-02-12 21:45:1313class PrefRegistrySyncable;
[email protected]443e9312013-05-06 06:17:3414}
[email protected]7688968a2013-02-12 21:45:1315
maxbogueea16ff412016-10-28 16:35:2916namespace sync_preferences {
sdefresne50c1e522015-09-18 09:47:5117
[email protected]7688968a2013-02-12 21:45:1318// Test version of PrefServiceSyncable.
Tim Schumann978e7502018-05-07 13:46:5219// 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 Huang41b07ab2020-03-27 21:40:3026// -- it hides the dependency injection of the different stores
27// -- just to later offer ways to manipulate specific stores.
Tim Schumann978e7502018-05-07 13:46:5228// -- 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]7688968a2013-02-12 21:45:1331class TestingPrefServiceSyncable
[email protected]443e9312013-05-06 06:17:3432 : public TestingPrefServiceBase<PrefServiceSyncable,
33 user_prefs::PrefRegistrySyncable> {
[email protected]7688968a2013-02-12 21:45:1334 public:
35 TestingPrefServiceSyncable();
[email protected]443e9312013-05-06 06:17:3436 TestingPrefServiceSyncable(TestingPrefStore* managed_prefs,
Toby Huang41b07ab2020-03-27 21:40:3037 TestingPrefStore* supervised_user_prefs,
a-v-y658f626b2017-01-09 09:18:4638 TestingPrefStore* extension_prefs,
[email protected]443e9312013-05-06 06:17:3439 TestingPrefStore* user_prefs,
40 TestingPrefStore* recommended_prefs,
41 user_prefs::PrefRegistrySyncable* pref_registry,
42 PrefNotifierImpl* pref_notifier);
dchenge59c1bb92014-10-21 11:55:4943 ~TestingPrefServiceSyncable() override;
[email protected]7688968a2013-02-12 21:45:1344
45 // This is provided as a convenience; on a production PrefService
46 // you would do all registrations before constructing it, passing it
[email protected]e90a01f2013-11-19 04:22:1247 // a PrefRegistry via its constructor (or via e.g. PrefServiceFactory).
[email protected]443e9312013-05-06 06:17:3448 user_prefs::PrefRegistrySyncable* registry();
[email protected]7688968a2013-02-12 21:45:1349
50 private:
51 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSyncable);
52};
53
maxbogueea16ff412016-10-28 16:35:2954} // namespace sync_preferences
sdefresne50c1e522015-09-18 09:47:5155
[email protected]443e9312013-05-06 06:17:3456template <>
maxbogueea16ff412016-10-28 16:35:2957TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
sdefresne50c1e522015-09-18 09:47:5158 user_prefs::PrefRegistrySyncable>::
[email protected]443e9312013-05-06 06:17:3459 TestingPrefServiceBase(TestingPrefStore* managed_prefs,
Toby Huang41b07ab2020-03-27 21:40:3060 TestingPrefStore* supervised_user_prefs,
a-v-y658f626b2017-01-09 09:18:4661 TestingPrefStore* extension_prefs,
[email protected]443e9312013-05-06 06:17:3462 TestingPrefStore* user_prefs,
63 TestingPrefStore* recommended_prefs,
64 user_prefs::PrefRegistrySyncable* pref_registry,
65 PrefNotifierImpl* pref_notifier);
[email protected]7688968a2013-02-12 21:45:1366
maxbogueea16ff412016-10-28 16:35:2967#endif // COMPONENTS_SYNC_PREFERENCES_TESTING_PREF_SERVICE_SYNCABLE_H_