Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/test/base/testing_pref_service.h

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to desired interfaces. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_ 5 #ifndef CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
6 #define CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_ 6 #define CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/testing_pref_store.h" 10 #include "base/prefs/testing_pref_store.h"
11 #include "chrome/browser/prefs/pref_registry.h"
10 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
11 13
12 class DefaultPrefStore; 14 class DefaultPrefStore;
13 class PrefModelAssociator; 15 class PrefModelAssociator;
14 class PrefNotifierImpl; 16 class PrefNotifierImpl;
17 class PrefRegistrySimple;
15 class TestingBrowserProcess; 18 class TestingBrowserProcess;
16 class TestingPrefStore; 19 class TestingPrefStore;
17 20
18 // A PrefService subclass for testing. It operates totally in memory and 21 // A PrefService subclass for testing. It operates totally in memory and
19 // provides additional API for manipulating preferences at the different levels 22 // provides additional API for manipulating preferences at the different levels
20 // (managed, extension, user) conveniently. 23 // (managed, extension, user) conveniently.
21 // 24 //
22 // Use this via its specializations, TestingPrefServiceSimple and 25 // Use this via its specializations, TestingPrefServiceSimple and
23 // TestingPrefServiceSyncable. 26 // TestingPrefServiceSyncable.
24 template <class SuperPrefService> 27 template <class SuperPrefService>
(...skipping 21 matching lines...) Expand all
46 // Similar to the above, but for recommended policy preferences. 49 // Similar to the above, but for recommended policy preferences.
47 const Value* GetRecommendedPref(const char* path) const; 50 const Value* GetRecommendedPref(const char* path) const;
48 void SetRecommendedPref(const char* path, Value* value); 51 void SetRecommendedPref(const char* path, Value* value);
49 void RemoveRecommendedPref(const char* path); 52 void RemoveRecommendedPref(const char* path);
50 53
51 protected: 54 protected:
52 TestingPrefServiceBase( 55 TestingPrefServiceBase(
53 TestingPrefStore* managed_prefs, 56 TestingPrefStore* managed_prefs,
54 TestingPrefStore* user_prefs, 57 TestingPrefStore* user_prefs,
55 TestingPrefStore* recommended_prefs, 58 TestingPrefStore* recommended_prefs,
56 DefaultPrefStore* default_store, 59 scoped_ptr<PrefRegistry> pref_registry,
57 PrefNotifierImpl* pref_notifier); 60 PrefNotifierImpl* pref_notifier);
58 61
59 private: 62 private:
60 // Reads the value of the preference indicated by |path| from |pref_store|. 63 // Reads the value of the preference indicated by |path| from |pref_store|.
61 // Returns NULL if the preference was not found. 64 // Returns NULL if the preference was not found.
62 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const; 65 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const;
63 66
64 // Sets the value for |path| in |pref_store|. 67 // Sets the value for |path| in |pref_store|.
65 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value); 68 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value);
66 69
67 // Removes the preference identified by |path| from |pref_store|. 70 // Removes the preference identified by |path| from |pref_store|.
68 void RemovePref(TestingPrefStore* pref_store, const char* path); 71 void RemovePref(TestingPrefStore* pref_store, const char* path);
69 72
70 // Pointers to the pref stores our value store uses. 73 // Pointers to the pref stores our value store uses.
71 scoped_refptr<TestingPrefStore> managed_prefs_; 74 scoped_refptr<TestingPrefStore> managed_prefs_;
72 scoped_refptr<TestingPrefStore> user_prefs_; 75 scoped_refptr<TestingPrefStore> user_prefs_;
73 scoped_refptr<TestingPrefStore> recommended_prefs_; 76 scoped_refptr<TestingPrefStore> recommended_prefs_;
74 77
75 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase); 78 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase);
76 }; 79 };
77 80
78 // Test version of PrefServiceSimple. 81 // Test version of PrefService.
79 class TestingPrefServiceSimple 82 class TestingPrefServiceSimple
80 : public TestingPrefServiceBase<PrefServiceSimple> { 83 : public TestingPrefServiceBase<PrefService> {
81 public: 84 public:
82 TestingPrefServiceSimple(); 85 TestingPrefServiceSimple();
83 virtual ~TestingPrefServiceSimple(); 86 virtual ~TestingPrefServiceSimple();
84 87
88 PrefRegistrySimple* registry() const;
89
85 private: 90 private:
86 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple); 91 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple);
87 }; 92 };
88 93
89 // Test version of PrefServiceSyncable. 94 // Test version of PrefServiceSyncable.
90 class TestingPrefServiceSyncable 95 class TestingPrefServiceSyncable
91 : public TestingPrefServiceBase<PrefServiceSyncable> { 96 : public TestingPrefServiceBase<PrefServiceSyncable> {
92 public: 97 public:
93 TestingPrefServiceSyncable(); 98 TestingPrefServiceSyncable();
94 virtual ~TestingPrefServiceSyncable(); 99 virtual ~TestingPrefServiceSyncable();
(...skipping 14 matching lines...) Expand all
109 } 114 }
110 115
111 private: 116 private:
112 TestingBrowserProcess* browser_process_; 117 TestingBrowserProcess* browser_process_;
113 TestingPrefServiceSimple local_state_; 118 TestingPrefServiceSimple local_state_;
114 119
115 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState); 120 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState);
116 }; 121 };
117 122
118 template<> 123 template<>
119 TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase( 124 TestingPrefServiceBase<PrefService>::TestingPrefServiceBase(
120 TestingPrefStore* managed_prefs, 125 TestingPrefStore* managed_prefs,
121 TestingPrefStore* user_prefs, 126 TestingPrefStore* user_prefs,
122 TestingPrefStore* recommended_prefs, 127 TestingPrefStore* recommended_prefs,
123 DefaultPrefStore* default_store, 128 scoped_ptr<PrefRegistry> pref_registry,
124 PrefNotifierImpl* pref_notifier); 129 PrefNotifierImpl* pref_notifier);
125 130
126 template<> 131 template<>
127 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase( 132 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
128 TestingPrefStore* managed_prefs, 133 TestingPrefStore* managed_prefs,
129 TestingPrefStore* user_prefs, 134 TestingPrefStore* user_prefs,
130 TestingPrefStore* recommended_prefs, 135 TestingPrefStore* recommended_prefs,
131 DefaultPrefStore* default_store, 136 scoped_ptr<PrefRegistry> pref_registry,
132 PrefNotifierImpl* pref_notifier); 137 PrefNotifierImpl* pref_notifier);
133 138
134 template<class SuperPrefService> 139 template<class SuperPrefService>
135 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() { 140 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() {
136 } 141 }
137 142
138 template<class SuperPrefService> 143 template<class SuperPrefService>
139 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref( 144 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref(
140 const char* path) const { 145 const char* path) const {
141 return GetPref(managed_prefs_, path); 146 return GetPref(managed_prefs_, path);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 pref_store->SetValue(path, value); 207 pref_store->SetValue(path, value);
203 } 208 }
204 209
205 template<class SuperPrefService> 210 template<class SuperPrefService>
206 void TestingPrefServiceBase<SuperPrefService>::RemovePref( 211 void TestingPrefServiceBase<SuperPrefService>::RemovePref(
207 TestingPrefStore* pref_store, const char* path) { 212 TestingPrefStore* pref_store, const char* path) {
208 pref_store->RemoveValue(path); 213 pref_store->RemoveValue(path);
209 } 214 }
210 215
211 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_ 216 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698