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

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: Fix double registration in Chrome Frame test. 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
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | chrome/test/base/testing_pref_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This is provided as a convenience for registering preferences on
88 // an existing TestingPrefServiceSimple instance. On a production
89 // PrefService you would do all registrations before constructing
90 // it, passing it a PrefRegistry via its constructor (or via
91 // e.g. PrefServiceBuilder).
92 PrefRegistrySimple* registry();
93
85 private: 94 private:
86 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple); 95 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceSimple);
87 }; 96 };
88 97
89 // Test version of PrefServiceSyncable. 98 // Test version of PrefServiceSyncable.
90 class TestingPrefServiceSyncable 99 class TestingPrefServiceSyncable
91 : public TestingPrefServiceBase<PrefServiceSyncable> { 100 : public TestingPrefServiceBase<PrefServiceSyncable> {
92 public: 101 public:
93 TestingPrefServiceSyncable(); 102 TestingPrefServiceSyncable();
94 virtual ~TestingPrefServiceSyncable(); 103 virtual ~TestingPrefServiceSyncable();
(...skipping 14 matching lines...) Expand all
109 } 118 }
110 119
111 private: 120 private:
112 TestingBrowserProcess* browser_process_; 121 TestingBrowserProcess* browser_process_;
113 TestingPrefServiceSimple local_state_; 122 TestingPrefServiceSimple local_state_;
114 123
115 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState); 124 DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState);
116 }; 125 };
117 126
118 template<> 127 template<>
119 TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase( 128 TestingPrefServiceBase<PrefService>::TestingPrefServiceBase(
120 TestingPrefStore* managed_prefs, 129 TestingPrefStore* managed_prefs,
121 TestingPrefStore* user_prefs, 130 TestingPrefStore* user_prefs,
122 TestingPrefStore* recommended_prefs, 131 TestingPrefStore* recommended_prefs,
123 DefaultPrefStore* default_store, 132 PrefRegistry* pref_registry,
124 PrefNotifierImpl* pref_notifier); 133 PrefNotifierImpl* pref_notifier);
125 134
126 template<> 135 template<>
127 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase( 136 TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
128 TestingPrefStore* managed_prefs, 137 TestingPrefStore* managed_prefs,
129 TestingPrefStore* user_prefs, 138 TestingPrefStore* user_prefs,
130 TestingPrefStore* recommended_prefs, 139 TestingPrefStore* recommended_prefs,
131 DefaultPrefStore* default_store, 140 PrefRegistry* pref_registry,
132 PrefNotifierImpl* pref_notifier); 141 PrefNotifierImpl* pref_notifier);
133 142
134 template<class SuperPrefService> 143 template<class SuperPrefService>
135 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() { 144 TestingPrefServiceBase<SuperPrefService>::~TestingPrefServiceBase() {
136 } 145 }
137 146
138 template<class SuperPrefService> 147 template<class SuperPrefService>
139 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref( 148 const Value* TestingPrefServiceBase<SuperPrefService>::GetManagedPref(
140 const char* path) const { 149 const char* path) const {
141 return GetPref(managed_prefs_, path); 150 return GetPref(managed_prefs_, path);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 pref_store->SetValue(path, value); 211 pref_store->SetValue(path, value);
203 } 212 }
204 213
205 template<class SuperPrefService> 214 template<class SuperPrefService>
206 void TestingPrefServiceBase<SuperPrefService>::RemovePref( 215 void TestingPrefServiceBase<SuperPrefService>::RemovePref(
207 TestingPrefStore* pref_store, const char* path) { 216 TestingPrefStore* pref_store, const char* path) {
208 pref_store->RemoveValue(path); 217 pref_store->RemoveValue(path);
209 } 218 }
210 219
211 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_ 220 #endif // CHROME_TEST_BASE_TESTING_PREF_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/test/base/testing_browser_process.cc ('k') | chrome/test/base/testing_pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698