testing_pref_service_syncable.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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#include "chrome/test/base/testing_pref_service_syncable.h"
6
7#include "base/bind.h"
8#include "base/prefs/pref_notifier_impl.h"
9#include "base/prefs/pref_value_store.h"
10#include "components/user_prefs/pref_registry_syncable.h"
11#include "testing/gtest/include/gtest/gtest.h"
12
13template<>
14TestingPrefServiceBase<PrefServiceSyncable, PrefRegistrySyncable>::
15TestingPrefServiceBase(TestingPrefStore* managed_prefs,
16                       TestingPrefStore* user_prefs,
17                       TestingPrefStore* recommended_prefs,
18                       PrefRegistrySyncable* pref_registry,
19                       PrefNotifierImpl* pref_notifier)
20    : PrefServiceSyncable(
21        pref_notifier,
22        new PrefValueStore(
23            managed_prefs,
24            NULL,
25            NULL,
26            user_prefs,
27            recommended_prefs,
28            pref_registry->defaults(),
29            pref_notifier),
30        user_prefs,
31        pref_registry,
32        base::Bind(
33            &TestingPrefServiceBase<PrefServiceSyncable,
34                                    PrefRegistrySyncable>::HandleReadError),
35        false),
36      managed_prefs_(managed_prefs),
37      user_prefs_(user_prefs),
38      recommended_prefs_(recommended_prefs) {
39}
40
41TestingPrefServiceSyncable::TestingPrefServiceSyncable()
42    : TestingPrefServiceBase<PrefServiceSyncable, PrefRegistrySyncable>(
43        new TestingPrefStore(),
44        new TestingPrefStore(),
45        new TestingPrefStore(),
46        new PrefRegistrySyncable(),
47        new PrefNotifierImpl()) {
48}
49
50TestingPrefServiceSyncable::TestingPrefServiceSyncable(
51    TestingPrefStore* managed_prefs,
52    TestingPrefStore* user_prefs,
53    TestingPrefStore* recommended_prefs,
54    PrefRegistrySyncable* pref_registry,
55    PrefNotifierImpl* pref_notifier)
56    : TestingPrefServiceBase<PrefServiceSyncable, PrefRegistrySyncable>(
57        managed_prefs,
58        user_prefs,
59        recommended_prefs,
60        pref_registry,
61        pref_notifier) {
62}
63
64TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {
65}
66
67PrefRegistrySyncable* TestingPrefServiceSyncable::registry() {
68  return static_cast<PrefRegistrySyncable*>(DeprecatedGetPrefRegistry());
69}
70