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

Unified Diff: tools/json_schema_compiler/util.h

Issue 1841483002: [Extensions] Convert APIs to use movable types [11] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « extensions/common/api/printer_provider/usb_printer_manifest_data.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/util.h
diff --git a/tools/json_schema_compiler/util.h b/tools/json_schema_compiler/util.h
index 945f06143e5d8f00dcea9397bac7ef39a05b64eb..d5eec1b2e1c49ee415e0b7fa209148a6f0d5c5f7 100644
--- a/tools/json_schema_compiler/util.h
+++ b/tools/json_schema_compiler/util.h
@@ -86,6 +86,20 @@ bool PopulateItem(const base::Value& from,
return true;
}
+// This template is used for types generated by tools/json_schema_compiler with
+// error generation enabled.
+template <class T>
+bool PopulateItem(const base::Value& from, T* out, base::string16* error) {
+ const base::DictionaryValue* dict = nullptr;
+ if (!from.GetAsDictionary(&dict))
+ return false;
+ T obj;
+ if (!T::Populate(*dict, &obj, error))
+ return false;
+ *out = std::move(obj);
+ return true;
+}
+
// Populates |out| with |list|. Returns false if there is no list at the
// specified key or if the list has anything other than |T|.
template <class T>
@@ -114,7 +128,7 @@ bool PopulateArrayFromList(const base::ListValue& list,
for (const base::Value* value : list) {
if (!PopulateItem(*value, &item, error))
return false;
- out->push_back(item);
+ out->push_back(std::move(item));
}
return true;
« no previous file with comments | « extensions/common/api/printer_provider/usb_printer_manifest_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698