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

Unified Diff: ppapi/shared_impl/var_value_conversions.cc

Issue 13080002: Apps V2 in Pepper: introduce singleton resource ExtensionsCommon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 | « ppapi/shared_impl/var_value_conversions.h ('k') | ppapi/shared_impl/var_value_conversions_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/var_value_conversions.cc
diff --git a/ppapi/shared_impl/var_value_conversions.cc b/ppapi/shared_impl/var_value_conversions.cc
index 614002a5eae4a113cdf7eb5a910da7ec132d78b5..46f316186879610aa6027569219ce669df96d88c 100644
--- a/ppapi/shared_impl/var_value_conversions.cc
+++ b/ppapi/shared_impl/var_value_conversions.cc
@@ -249,9 +249,11 @@ base::Value* CreateValueFromVar(const PP_Var& var) {
dict_var->key_value_map().begin();
iter != dict_var->key_value_map().end();
++iter) {
- // Skip the key-value pair if the value is undefined.
- if (iter->second.get().type == PP_VARTYPE_UNDEFINED)
+ // Skip the key-value pair if the value is undefined or null.
+ if (iter->second.get().type == PP_VARTYPE_UNDEFINED ||
+ iter->second.get().type == PP_VARTYPE_NULL) {
continue;
+ }
scoped_ptr<base::Value> child_value;
if (!CreateValueFromVarHelper(parent_ids, iter->second.get(),
@@ -340,5 +342,50 @@ PP_Var CreateVarFromValue(const base::Value& value) {
return root_var.Release();
}
+
+base::ListValue* CreateListValueFromVarVector(
+ const std::vector<PP_Var>& vars) {
+ scoped_ptr<base::ListValue> list_value(new base::ListValue());
+
+ for (std::vector<PP_Var>::const_iterator iter = vars.begin();
+ iter != vars.end();
+ ++iter) {
+ base::Value* value = CreateValueFromVar(*iter);
+ if (!value)
+ return NULL;
+ list_value->Append(value);
+ }
+ return list_value.release();
+}
+
+bool CreateVarVectorFromListValue(const base::ListValue& list_value,
+ std::vector<PP_Var>* vars) {
+ if (!vars)
+ return false;
+
+ std::vector<ScopedPPVar> result;
+ result.reserve(list_value.GetSize());
+ for (base::ListValue::const_iterator iter = list_value.begin();
+ iter != list_value.end();
+ ++iter) {
+ ScopedPPVar child_var(ScopedPPVar::PassRef(),
+ CreateVarFromValue(**iter));
+ if (child_var.get().type == PP_VARTYPE_UNDEFINED)
+ return false;
+
+ result.push_back(child_var);
+ }
+
+ vars->clear();
+ vars->reserve(result.size());
+ for (std::vector<ScopedPPVar>::iterator iter = result.begin();
+ iter != result.end();
+ ++iter) {
+ vars->push_back(iter->Release());
+ }
+
+ return true;
+}
+
} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/var_value_conversions.h ('k') | ppapi/shared_impl/var_value_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698