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

Unified Diff: base/prefs/pref_service.cc

Issue 81183005: Remove JsonPrefStore pruning of empty values on write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove else Created 7 years, 1 month 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 | « base/prefs/pref_service.h ('k') | base/prefs/testing_pref_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/pref_service.cc
diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc
index 4c707a50d6c231137055bf27b7930f945aa3045e..576043b54894913fa40491057f91fc12b954f811 100644
--- a/base/prefs/pref_service.cc
+++ b/base/prefs/pref_service.cc
@@ -53,20 +53,12 @@ PrefService::PrefService(
read_error_callback_(read_error_callback) {
pref_notifier_->SetPrefService(this);
- pref_registry_->SetRegistrationCallback(
- base::Bind(&PrefService::AddRegisteredPreference,
- base::Unretained(this)));
- AddInitialPreferences();
-
InitFromStorage(async);
}
PrefService::~PrefService() {
DCHECK(CalledOnValidThread());
- // Remove our callback, setting a NULL one.
- pref_registry_->SetRegistrationCallback(PrefRegistry::RegistrationCallback());
-
// Reset pointers so accesses after destruction reliably crash.
pref_value_store_.reset();
pref_registry_ = NULL;
@@ -297,10 +289,6 @@ const base::Value* PrefService::GetDefaultPrefValue(const char* path) const {
return value;
}
-void PrefService::MarkUserStoreNeedsEmptyValue(const std::string& key) const {
- user_pref_store_->MarkNeedsEmptyValue(key);
-}
-
const base::ListValue* PrefService::GetList(const char* path) const {
DCHECK(CalledOnValidThread());
@@ -332,42 +320,6 @@ PrefRegistry* PrefService::DeprecatedGetPrefRegistry() {
return pref_registry_.get();
}
-void PrefService::AddInitialPreferences() {
- for (PrefRegistry::const_iterator it = pref_registry_->begin();
- it != pref_registry_->end();
- ++it) {
- AddRegisteredPreference(it->first.c_str(), it->second);
- }
-}
-
-// TODO(joi): Once MarkNeedsEmptyValue is gone, we can probably
-// completely get rid of this method. There will be one difference in
-// semantics; currently all registered preferences are stored right
-// away in the prefs_map_, if we remove this they would be stored only
-// opportunistically.
-void PrefService::AddRegisteredPreference(const char* path,
- base::Value* default_value) {
- DCHECK(CalledOnValidThread());
-
- // For ListValue and DictionaryValue with non empty default, empty value
- // for |path| needs to be persisted in |user_pref_store_|. So that
- // non empty default is not used when user sets an empty ListValue or
- // DictionaryValue.
- bool needs_empty_value = false;
- base::Value::Type orig_type = default_value->GetType();
- if (orig_type == base::Value::TYPE_LIST) {
- const base::ListValue* list = NULL;
- if (default_value->GetAsList(&list) && !list->empty())
- needs_empty_value = true;
- } else if (orig_type == base::Value::TYPE_DICTIONARY) {
- const base::DictionaryValue* dict = NULL;
- if (default_value->GetAsDictionary(&dict) && !dict->empty())
- needs_empty_value = true;
- }
- if (needs_empty_value)
- user_pref_store_->MarkNeedsEmptyValue(path);
-}
-
void PrefService::ClearPref(const char* path) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « base/prefs/pref_service.h ('k') | base/prefs/testing_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698