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

Unified Diff: base/values.cc

Issue 12092021: Remove PersistentPrefStore::MarkNeedsEmptyValue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some tests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 9228ca9b7690cc4644a19a9fda6c8aa24fd56f40..5ec8d582998fe37bf26114890e308ef756f32962 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -462,8 +462,8 @@ void DictionaryValue::SetStringWithoutPathExpansion(
SetWithoutPathExpansion(path, CreateStringValue(in_value));
}
-bool DictionaryValue::Get(
- const std::string& path, const Value** out_value) const {
+bool DictionaryValue::Get(const std::string& path,
+ const Value** out_value) const {
DCHECK(IsStringUTF8(path));
std::string current_path(path);
const DictionaryValue* current_dictionary = this;
@@ -751,6 +751,24 @@ bool DictionaryValue::RemoveWithoutPathExpansion(const std::string& key,
return true;
}
+bool DictionaryValue::RemovePath(const std::string& path, Value** out_value) {
+ bool result = false;
+ size_t delimiter_position = path.find('.');
+ if (delimiter_position == std::string::npos) {
+ return RemoveWithoutPathExpansion(path, out_value);
+ } else {
+ const std::string subdict_path = path.substr(0, delimiter_position);
+ DictionaryValue* subdict = NULL;
+ if (!GetDictionary(subdict_path, &subdict))
+ return false;
+ result = subdict->RemovePath(path.substr(delimiter_position + 1),
+ out_value);
+ if (result && subdict->empty())
+ Remove(subdict_path, NULL);
+ }
+ return result;
+}
+
DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() {
Value* copy = CopyWithoutEmptyChildren(this);
return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue;
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698