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

Unified Diff: chrome/test/base/testing_pref_service.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/testing_pref_service.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_pref_service.cc
diff --git a/chrome/test/base/testing_pref_service.cc b/chrome/test/base/testing_pref_service.cc
index 177ec3555c9dcbe8d397d2e1335926193c72cb74..ce15d0904be1ce0ca80cce2534b4a3bb31fd0df5 100644
--- a/chrome/test/base/testing_pref_service.cc
+++ b/chrome/test/base/testing_pref_service.cc
@@ -6,120 +6,90 @@
#include "base/bind.h"
#include "base/prefs/default_pref_store.h"
-#include "base/prefs/testing_pref_store.h"
-#include "chrome/browser/policy/configuration_policy_pref_store.h"
#include "chrome/browser/prefs/browser_prefs.h"
-#include "chrome/browser/prefs/command_line_pref_store.h"
-#include "chrome/browser/prefs/pref_model_associator.h"
#include "chrome/browser/prefs/pref_notifier_impl.h"
#include "chrome/browser/prefs/pref_value_store.h"
#include "chrome/test/base/testing_browser_process.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/l10n/l10n_util.h"
namespace {
-// Do-nothing implementation for PrefService.
+// Do-nothing implementation for TestingPrefService.
void HandleReadError(PersistentPrefStore::PrefReadError error) {
}
} // namespace
-TestingPrefServiceBase::TestingPrefServiceBase(
+template<>
+TestingPrefServiceBase<PrefServiceSimple>::TestingPrefServiceBase(
TestingPrefStore* managed_prefs,
TestingPrefStore* user_prefs,
TestingPrefStore* recommended_prefs,
DefaultPrefStore* default_store,
- PrefModelAssociator* pref_sync_associator,
PrefNotifierImpl* pref_notifier)
- : PrefService(pref_notifier,
- new PrefValueStore(
- managed_prefs,
- NULL,
- NULL,
- user_prefs,
- recommended_prefs,
- default_store,
- pref_sync_associator,
- pref_notifier),
- user_prefs,
- default_store,
- pref_sync_associator,
- base::Bind(&HandleReadError),
- false),
+ : PrefServiceSimple(pref_notifier,
+ new PrefValueStore(
+ managed_prefs,
+ NULL,
+ NULL,
+ user_prefs,
+ recommended_prefs,
+ default_store,
+ pref_notifier),
+ user_prefs,
+ default_store,
+ base::Bind(&HandleReadError),
+ false),
managed_prefs_(managed_prefs),
user_prefs_(user_prefs),
recommended_prefs_(recommended_prefs) {
}
-TestingPrefServiceBase::~TestingPrefServiceBase() {
-}
-
-const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const {
- return GetPref(managed_prefs_, path);
-}
-
-void TestingPrefServiceBase::SetManagedPref(const char* path, Value* value) {
- SetPref(managed_prefs_, path, value);
-}
-
-void TestingPrefServiceBase::RemoveManagedPref(const char* path) {
- RemovePref(managed_prefs_, path);
-}
-
-const Value* TestingPrefServiceBase::GetUserPref(const char* path) const {
- return GetPref(user_prefs_, path);
-}
-
-void TestingPrefServiceBase::SetUserPref(const char* path, Value* value) {
- SetPref(user_prefs_, path, value);
-}
-
-void TestingPrefServiceBase::RemoveUserPref(const char* path) {
- RemovePref(user_prefs_, path);
-}
-
-const Value* TestingPrefServiceBase::GetRecommendedPref(
- const char* path) const {
- return GetPref(recommended_prefs_, path);
-}
-
-void TestingPrefServiceBase::SetRecommendedPref(
- const char* path, Value* value) {
- SetPref(recommended_prefs_, path, value);
-}
-
-void TestingPrefServiceBase::RemoveRecommendedPref(const char* path) {
- RemovePref(recommended_prefs_, path);
-}
-
-const Value* TestingPrefServiceBase::GetPref(TestingPrefStore* pref_store,
- const char* path) const {
- const Value* res;
- return pref_store->GetValue(path, &res) ? res : NULL;
+template<>
+TestingPrefServiceBase<PrefServiceSyncable>::TestingPrefServiceBase(
+ TestingPrefStore* managed_prefs,
+ TestingPrefStore* user_prefs,
+ TestingPrefStore* recommended_prefs,
+ DefaultPrefStore* default_store,
+ PrefNotifierImpl* pref_notifier)
+ : PrefServiceSyncable(pref_notifier,
+ new PrefValueStore(
+ managed_prefs,
+ NULL,
+ NULL,
+ user_prefs,
+ recommended_prefs,
+ default_store,
+ pref_notifier),
+ user_prefs,
+ default_store,
+ base::Bind(&HandleReadError),
+ false),
+ managed_prefs_(managed_prefs),
+ user_prefs_(user_prefs),
+ recommended_prefs_(recommended_prefs) {
}
-void TestingPrefServiceBase::SetPref(TestingPrefStore* pref_store,
- const char* path,
- Value* value) {
- pref_store->SetValue(path, value);
+TestingPrefServiceSimple::TestingPrefServiceSimple()
+ : TestingPrefServiceBase<PrefServiceSimple>(new TestingPrefStore(),
+ new TestingPrefStore(),
+ new TestingPrefStore(),
+ new DefaultPrefStore(),
+ new PrefNotifierImpl()) {
}
-void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store,
- const char* path) {
- pref_store->RemoveValue(path);
+TestingPrefServiceSimple::~TestingPrefServiceSimple() {
}
-TestingPrefService::TestingPrefService()
- : TestingPrefServiceBase(new TestingPrefStore(),
- new TestingPrefStore(),
- new TestingPrefStore(),
- new DefaultPrefStore(),
- new PrefModelAssociator(),
- new PrefNotifierImpl()) {
+TestingPrefServiceSyncable::TestingPrefServiceSyncable()
+ : TestingPrefServiceBase<PrefServiceSyncable>(new TestingPrefStore(),
+ new TestingPrefStore(),
+ new TestingPrefStore(),
+ new DefaultPrefStore(),
+ new PrefNotifierImpl()) {
}
-TestingPrefService::~TestingPrefService() {
+TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {
}
ScopedTestingLocalState::ScopedTestingLocalState(
« no previous file with comments | « chrome/test/base/testing_pref_service.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698