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

Unified Diff: components/policy/core/common/schema.cc

Issue 171403004: Add touch flag to output of Schema::Normalize() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split-1
Patch Set: rebase Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/schema.h ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/schema.cc
diff --git a/components/policy/core/common/schema.cc b/components/policy/core/common/schema.cc
index 180466b029ce57a2956fff3ca2dc15078da26683..d50bd8abc4d031cd8c445f32e5cb0626f5d8ad84 100644
--- a/components/policy/core/common/schema.cc
+++ b/components/policy/core/common/schema.cc
@@ -737,7 +737,8 @@ bool Schema::Validate(const base::Value& value,
bool Schema::Normalize(base::Value* value,
SchemaOnErrorStrategy strategy,
std::string* error_path,
- std::string* error) const {
+ std::string* error,
+ bool* changed) const {
if (!valid()) {
SchemaErrorFound(error_path, error, "The schema is invalid.");
return false;
@@ -776,7 +777,8 @@ bool Schema::Normalize(base::Value* value,
if (!subschema.Normalize(sub_value,
StrategyForNextLevel(strategy),
error_path,
- error)) {
+ error,
+ changed)) {
// Invalid property was detected.
AddDictKeyPrefixToPath(it.key(), error_path);
if (StrategyAllowInvalidOnTopLevel(strategy))
@@ -786,6 +788,8 @@ bool Schema::Normalize(base::Value* value,
}
}
}
+ if (changed && !drop_list.empty())
+ *changed = true;
for (std::vector<std::string>::const_iterator it = drop_list.begin();
it != drop_list.end();
++it) {
@@ -797,11 +801,11 @@ bool Schema::Normalize(base::Value* value,
for (size_t index = 0; index < list->GetSize(); index++) {
base::Value* sub_value = NULL;
list->Get(index, &sub_value);
- if (!sub_value ||
- !GetItems().Normalize(sub_value,
- StrategyForNextLevel(strategy),
- error_path,
- error)) {
+ if (!sub_value || !GetItems().Normalize(sub_value,
+ StrategyForNextLevel(strategy),
+ error_path,
+ error,
+ changed)) {
// Invalid list item was detected.
AddListIndexPrefixToPath(index, error_path);
if (StrategyAllowInvalidOnTopLevel(strategy))
@@ -810,6 +814,8 @@ bool Schema::Normalize(base::Value* value,
return false;
}
}
+ if (changed && !drop_list.empty())
+ *changed = true;
for (std::vector<size_t>::reverse_iterator it = drop_list.rbegin();
it != drop_list.rend(); ++it) {
list->Remove(*it, NULL);
« no previous file with comments | « components/policy/core/common/schema.h ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698