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

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: Update production interfaces based on review comments. Created 7 years, 10 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;
13 class PrefModelAssociator; 14 class PrefModelAssociator;
14 class PrefNotifierImpl; 15 class PrefNotifierImpl;
16 class PrefRegistrySimple;
15 class TestingBrowserProcess; 17 class TestingBrowserProcess;
16 class TestingPrefStore; 18 class TestingPrefStore;
17 19
18 // A PrefService subclass for testing. It operates totally in memory and 20 // A PrefService subclass for testing. It operates totally in memory and
19 // provides additional API for manipulating preferences at the different levels 21 // provides additional API for manipulating preferences at the different levels
20 // (managed, extension, user) conveniently. 22 // (managed, extension, user) conveniently.
21 // 23 //
22 // Use this via its specializations, TestingPrefServiceSimple and 24 // Use this via its specializations, TestingPrefServiceSimple and
23 // TestingPrefServiceSyncable. 25 // TestingPrefServiceSyncable.
24 template <class SuperPrefService> 26 template <class SuperPrefService>
(...skipping 21 matching lines...) Expand all
46 // Similar to the above, but for recommended policy preferences. 48 // Similar to the above, but for recommended policy preferences.
47 const Value* GetRecommendedPref(const char* path) const; 49 const Value* GetRecommendedPref(const char* path) const;
48 void SetRecommendedPref(const char* path, Value* value); 50 void SetRecommendedPref(const char* path, Value* value);
49 void RemoveRecommendedPref(const char* path); 51 void RemoveRecommendedPref(const char* path);
50 52
51 protected: 53 protected:
52 TestingPrefServiceBase( 54 TestingPrefServiceBase(
53 TestingPrefStore* managed_prefs, 55 TestingPrefStore* managed_prefs,
54 TestingPrefStore* user_prefs, 56 TestingPrefStore* user_prefs,
55 TestingPrefStore* recommended_prefs, 57 TestingPrefStore* recommended_prefs,
56 DefaultPrefStore* default_store, 58 PrefRegistry* pref_registry,
57 PrefNotifierImpl* pref_notifier); 59 PrefNotifierImpl* pref_notifier);
58 60
59 private: 61 private:
60 // Reads the value of the preference indicated by |path| from |pref_store|. 62 // Reads the value of the preference indicated by |path| from |pref_store|.
61 // Returns NULL if the preference was not found. 63 // Returns NULL if the preference was not found.
62 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const; 64 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const;
63 65
64 // Sets the value for |path| in |pref_store|. 66 // Sets the value for |path| in |pref_store|.
65 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value); 67 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value);
66 68
67 // Removes the preference identified by |path| from |pref_store|. 69 // Removes the preference identified by |path| from |pref_store|.
68 void RemovePref(TestingPrefStore* pref_store, const char* path); 70 void RemovePref(TestingPrefStore* pref_store, const char* path);
69 71
70 // Pointers to the pref stores our value store uses. 72 // Pointers to the pref stores our value store uses.
71 scoped_refptr<TestingPrefStore> managed_prefs_; 73 scoped_refptr<TestingPrefStore> managed_prefs_;
72 scoped_refptr<TestingPrefStore> user_prefs_; 74 scoped_refptr<TestingPrefStore> user_prefs_;
73 scoped_refptr<TestingPrefStore> recommended_prefs_; 75 scoped_refptr<TestingPrefStore> recommended_prefs_;
74 76
75 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase); 77 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase);
76 }; 78 };
77 79
78 // Test version of PrefServiceSimple. 80 // Test version of PrefService.
79 class TestingPrefServiceSimple 81 class TestingPrefServiceSimple
80 : public TestingPrefServiceBase<PrefServiceSimple> { 82 : public TestingPrefServiceBase<PrefService> {
81 public: 83 public:
82 TestingPrefServiceSimple(); 84 TestingPrefServiceSimple();
83 virtual ~TestingPrefServiceSimple(); 85 virtual ~TestingPrefServiceSimple();
84 86
87 PrefRegistrySimple* registry();
88
85 private: 89 private:
86 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple); 90 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple);
87 }; 91 };
88 92
89 // Test version of PrefServiceSyncable. 93 // Test version of PrefServiceSyncable.
90 class TestingPrefServiceSyncable 94 class TestingPrefServiceSyncable
91 : public TestingPrefServiceBase<PrefServiceSyncable> { 95 : public TestingPrefServiceBase<PrefServiceSyncable> {
92 public: 96 public:
93 TestingPrefServiceSyncable(); 97 TestingPrefServiceSyncable();
94 virtual ~TestingPrefServiceSyncable(); 98 virtual ~TestingPrefServiceSyncable();
(...skipping 14 matching lines...) Expand all
109 } 113 }
110 114
111 private: 115 private:
112 TestingBrowserProcess* browser_process_; 116 TestingBrowserProcess* browser_process_;
113 TestingPrefServiceSimple local_state_; 117 TestingPrefServiceSimple local_state_;
114 118
115 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState); 119 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState);
116 }; 120 };
117 121
118 template<> 122 template<>
119 TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase( 123 TestingPrefServiceBase<PrefService>::TestingPrefServiceBase(
120 TestingPrefStore* managed_prefs, 124 TestingPrefStore* managed_prefs,
121 TestingPrefStore* user_prefs, 125 TestingPrefStore* user_prefs,
122 TestingPrefStore* recommended_prefs, 126 TestingPrefStore* recommended_prefs,
123 DefaultPrefStore* default_store, 127 PrefRegistry* pref_registry,
124 PrefNotifierImpl* pref_notifier); 128 PrefNotifierImpl* pref_notifier);
125 129
126 template<> 130 template<>
127 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase( 131 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
128 TestingPrefStore* managed_prefs, 132 TestingPrefStore* managed_prefs,
129 TestingPrefStore* user_prefs, 133 TestingPrefStore* user_prefs,
130 TestingPrefStore* recommended_prefs, 134 TestingPrefStore* recommended_prefs,
131 DefaultPrefStore* default_store, 135 PrefRegistry* pref_registry,
132 PrefNotifierImpl* pref_notifier); 136 PrefNotifierImpl* pref_notifier);
133 137
134 template<class SuperPrefService> 138 template<class SuperPrefService>
135 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() { 139 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() {
136 } 140 }
137 141
138 template<class SuperPrefService> 142 template<class SuperPrefService>
139 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref( 143 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref(
140 const char* path) const { 144 const char* path) const {
141 return GetPref(managed_prefs_, path); 145 return GetPref(managed_prefs_, path);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 pref_store->SetValue(path, value); 206 pref_store->SetValue(path, value);
203 } 207 }
204 208
205 template<class SuperPrefService> 209 template<class SuperPrefService>
206 void TestingPrefServiceBase<SuperPrefService>::RemovePref( 210 void TestingPrefServiceBase<SuperPrefService>::RemovePref(
207 TestingPrefStore* pref_store, const char* path) { 211 TestingPrefStore* pref_store, const char* path) {
208 pref_store->RemoveValue(path); 212 pref_store->RemoveValue(path);
209 } 213 }
210 214
211 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_ 215 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698